浏览代码

Merge pull request #318 from anarcat/flake8

small flake8 changes
TW 9 年之前
父节点
当前提交
557d8c7e03
共有 4 个文件被更改,包括 19 次插入9 次删除
  1. 0 1
      borg/testsuite/logger.py
  2. 8 4
      borg/testsuite/upgrader.py
  3. 9 0
      docs/development.rst
  4. 2 4
      setup.cfg

+ 0 - 1
borg/testsuite/logger.py

@@ -1,6 +1,5 @@
 import logging
 from io import StringIO
-import sys
 
 from mock import Mock
 import pytest

+ 8 - 4
borg/testsuite/upgrader.py

@@ -1,6 +1,4 @@
 import os
-import shutil
-import tempfile
 
 import pytest
 
@@ -15,7 +13,7 @@ from ..upgrader import AtticRepositoryUpgrader, AtticKeyfileKey
 from ..helpers import get_keys_dir
 from ..key import KeyfileKey
 from ..remote import RemoteRepository
-from ..repository import Repository, MAGIC
+from ..repository import Repository
 
 
 def repo_valid(path):
@@ -61,10 +59,12 @@ def attic_repo(tmpdir):
     attic_repo.close()
     return attic_repo
 
+
 @pytest.fixture(params=[True, False])
 def inplace(request):
     return request.param
 
+
 @pytest.mark.skipif(attic is None, reason='cannot find an attic install')
 def test_convert_segments(tmpdir, attic_repo, inplace):
     """test segment conversion
@@ -159,10 +159,13 @@ def test_convert_all(tmpdir, attic_repo, attic_key_file, inplace):
     """
     # check should fail because of magic number
     assert not repo_valid(tmpdir)
+
     def stat_segment(path):
         return os.stat(os.path.join(path, 'data', '0', '0'))
+
     def first_inode(path):
         return stat_segment(path).st_ino
+
     orig_inode = first_inode(attic_repo.path)
     repo = AtticRepositoryUpgrader(str(tmpdir), create=False)
     # replicate command dispatch, partly
@@ -176,11 +179,12 @@ def test_convert_all(tmpdir, attic_repo, attic_key_file, inplace):
         assert first_inode(repo.path) != first_inode(backup)
         # i have seen cases where the copied tree has world-readable
         # permissions, which is wrong
-        assert stat_segment(backup).st_mode & 0o007== 0
+        assert stat_segment(backup).st_mode & 0o007 == 0
 
     assert key_valid(attic_key_file.path)
     assert repo_valid(tmpdir)
 
+
 def test_hardlink(tmpdir, inplace):
     """test that we handle hard links properly
 

+ 9 - 0
docs/development.rst

@@ -9,6 +9,15 @@ This chapter will get you started with |project_name|' development.
 |project_name| is written in Python (with a little bit of Cython and C for
 the performance critical parts).
 
+Style guide
+-----------
+
+We generally follow `pep8
+<https://www.python.org/dev/peps/pep-0008/>`_, with 120 columns
+instead of 79. We do *not* use form-feed (``^L``) characters to
+separate sections either. The `flake8
+<https://flake8.readthedocs.org/>`_ commandline tool should be used to
+check for style errors before sending pull requests.
 
 Building a development environment
 ----------------------------------

+ 2 - 4
setup.cfg

@@ -2,7 +2,5 @@
 python_files = testsuite/*.py
 
 [flake8]
-ignore = E226,F403
-max-line-length = 250
-exclude = docs/conf.py,borg/_version.py,build,dist,.git,.idea,.cache
-max-complexity = 100
+max-line-length = 120
+exclude = build,dist,.git,.idea,.cache,.tox