Browse Source

black integration

Andrey Bienkowski 3 years ago
parent
commit
adb1c36215
4 changed files with 23 additions and 2 deletions
  1. 12 0
      .github/workflows/black.yaml
  2. 4 0
      pyproject.toml
  3. 2 1
      setup.cfg
  4. 5 1
      src/borg/constants.py

+ 12 - 0
.github/workflows/black.yaml

@@ -0,0 +1,12 @@
+# https://black.readthedocs.io/en/stable/integrations/github_actions.html#usage
+
+name: Lint
+
+on: [push, pull_request]
+
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: psf/black@stable

+ 4 - 0
pyproject.toml

@@ -4,3 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [tool.setuptools_scm]
 write_to = "src/borg/_version.py"
+
+[tool.black]
+line-length = 120
+skip-magic-trailing-comma = true

+ 2 - 1
setup.cfg

@@ -106,7 +106,8 @@ markers =
 #   W504 line break after binary operator
 
 # borg code style guidelines:
-ignore = E226, W503
+# Ignoring E203 due to https://github.com/PyCQA/pycodestyle/issues/373
+ignore = E226, W503, E203
 
 # Code style violation exceptions:
 # please note that the values are adjusted so that they do not cause failures

+ 5 - 1
src/borg/constants.py

@@ -1,18 +1,22 @@
 # this set must be kept complete, otherwise the RobustUnpacker might malfunction:
+# fmt: off
 ITEM_KEYS = frozenset(['path', 'source', 'rdev', 'chunks', 'chunks_healthy', 'hardlink_master', 'hlid',
                        'mode', 'user', 'group', 'uid', 'gid', 'mtime', 'atime', 'ctime', 'birthtime', 'size',
                        'xattrs', 'bsdflags', 'acl_nfs4', 'acl_access', 'acl_default', 'acl_extended',
                        'part'])
+# fmt: on
 
 # this is the set of keys that are always present in items:
 REQUIRED_ITEM_KEYS = frozenset(['path', 'mtime', ])
 
 # this set must be kept complete, otherwise rebuild_manifest might malfunction:
+# fmt: off
 ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'hostname', 'username', 'time', 'time_end',
                           'comment', 'chunker_params',
                           'recreate_cmdline',
                           'recreate_source_id', 'recreate_args', 'recreate_partial_chunks',  # used in 1.1.0b1 .. b2
-                          'size', 'nfiles', 'size_parts', 'nfiles_parts', ])
+                          'size', 'nfiles', 'size_parts', 'nfiles_parts'])
+# fmt: on
 
 # this is the set of keys that are always present in archives:
 REQUIRED_ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'time', ])