]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: use black & isort on the smb module
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 30 Jan 2024 21:49:25 +0000 (16:49 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 25 Apr 2024 23:10:39 +0000 (19:10 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/tox.ini

index 5500166188ec99ba8b959039de84977eab2ed828..53a0a7766265b1a74b0d9f3b1e5d4b8e91a74088 100644 (file)
@@ -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}