From: John Mulligan Date: Tue, 30 Jan 2024 21:49:25 +0000 (-0500) Subject: pybind/mgr: use black & isort on the smb module X-Git-Tag: v20.0.0~2047^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3981d3d3841efc0c867c3f6084e4a5522c79e347;p=ceph.git pybind/mgr: use black & isort on the smb module Provide tox envs that check or reformat code with black and isort, currently applied to only the new smb module. This is similar to what we recently did for enabling tox in the cephadmlib dir as it only applies to new code. However, other modules that want to opt-in to automated, python-community-wide typical, stop-thinking-and-let-tools-do-it approach to code formatting can be added to the new envs later on. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 5500166188ec..53a0a7766265 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -6,6 +6,8 @@ envlist = flake8 jinjalint nooptional + check-black + check-isort skipsdist = true skip_missing_interpreters = true @@ -187,3 +189,45 @@ deps = jinjaninja commands = jinja-ninja cephadm/templates + + +# OPT-IN formatting with 'black' +# add your module to the modules list below to use automated formatting +[black] +deps = black>=23,<24 +options = -l78 -t py36 --skip-string-normalization +modules = smb + +[testenv:check-black] +deps = {[black]deps} +commands = + black --check -q {[black]options} {[black]modules} + +[testenv:format-black] +deps = {[black]deps} +commands = + black {[black]options} {[black]modules} + + +# OPT-IN import style formatting with 'isort' +# add your module to the modules list below to use automated import sorting +[isortcfg] +deps = isort +modules = smb + +[isort] +profile = black +line_length = 78 +known_first_party = ceph,rados,rbd,cephfs,mgr,mgr_module,mgr_util,object_format +known_typing = typing +sections = FUTURE,TYPING,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER + +[testenv:check-isort] +deps = {[isortcfg]deps} +commands = + isort --check-only {[isortcfg]modules} + +[testenv:format-isort] +deps = {[isortcfg]deps} +commands = + isort {[isortcfg]modules}