Move pep8 to pre-commit 80/85780/2
authorThanh Ha <zxiiro@gmail.com>
Fri, 15 Nov 2019 17:21:09 +0000 (12:21 -0500)
committerThanh Ha <zxiiro@gmail.com>
Fri, 15 Nov 2019 17:48:24 +0000 (12:48 -0500)
This final patch removes our dependency on coala which hasn't had
a release in quite some time.

Change-Id: Idf43965822f7ece83143fb7fa8c3ddda1175355a
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
.coafile [deleted file]
.flake8 [new file with mode: 0644]
.pre-commit-config.yaml
tools/fastbgp/play.py
tox.ini

diff --git a/.coafile b/.coafile
deleted file mode 100644 (file)
index 5b849f5..0000000
--- a/.coafile
+++ /dev/null
@@ -1,5 +0,0 @@
-[Python]
-bears = PEP8Bear
-files = **/*.py
-ignore = .*/**
-max_line_length = 120
diff --git a/.flake8 b/.flake8
new file mode 100644 (file)
index 0000000..5dca78b
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,18 @@
+[flake8]
+show-source = True
+max-line-length = 120
+
+# # - Select E121, E123, E126, E226, E241, E242 and E704 which are turned OFF
+# #   by default but represent guidelines accepted by us.
+# # - Do not select E133 because it is incompatible with E123 which was
+# #   selected instead.
+# - It turns out that now all checks except E133 are enabled so the select
+#   can be simplified to be just "E,W". However a new version could change
+#   that (select E133 instead of E123) but that should be caught by the
+#   verify job.
+select = E,W
+ignore = E722,W503 # as of aprox 10/25 some update/change has caused existing code to fail on E722
+exclude =
+    .git,
+    .tox,
+    docs/conf.py
index b726c5a88169e47599bc45f210ad901fd95a7410..2598d437f625971b97e5ebd4c1871b1d314de196 100644 (file)
@@ -1,4 +1,16 @@
 ---
+- repo: https://github.com/pre-commit/pre-commit-hooks
+  rev: v2.4.0  # Use the ref you want to point at
+  hooks:
+    - id: flake8
+      language_version: python2
+      additional_dependencies: ['flake8~=3.5.0']
+
+- repo: https://github.com/pre-commit/mirrors-autopep8
+  rev: v1.4.4
+  hooks:
+    - id: autopep8
+
 - repo: git://github.com/guykisel/pre-commit-robotframework-tidy
   rev: 'master'
   hooks:
index d04e2e75e7687127198bd4b07b656f5f846f9fed..d82cbab0073211264b61fc82eb93cddfe0fc25da 100755 (executable)
@@ -407,9 +407,11 @@ class MessageGenerator(object):
         s1_slots = ((self.total_prefix_amount -
                      self.remaining_prefixes_threshold - 1) /
                     self.prefix_count_to_add_default + 1)
-        s2_slots = ((self.remaining_prefixes_threshold - 1) /
-                    (self.prefix_count_to_add_default -
-                     self.prefix_count_to_del_default) + 1)
+        s2_slots = (
+            (self.remaining_prefixes_threshold - 1)
+            / (self.prefix_count_to_add_default - self.prefix_count_to_del_default)
+            + 1
+        )
         # S1_First_Index = 0
         # S1_Last_Index = s1_slots * self.prefix_count_to_add_default - 1
         s2_first_index = s1_slots * self.prefix_count_to_add_default
@@ -715,9 +717,10 @@ class MessageGenerator(object):
             if not self.phase2_start_time:
                 self.phase2_start_time = time.time()
         # tailor the number of prefixes if needed
-        prefix_count_to_add = (prefix_count_to_del +
-                               min(prefix_count_to_add - prefix_count_to_del,
-                                   self.remaining_prefixes))
+        prefix_count_to_add = (
+            prefix_count_to_del
+            + min(prefix_count_to_add - prefix_count_to_del, self.remaining_prefixes)
+        )
         # prefix slots selection for insertion and withdrawal
         slot_index_to_add = self.iteration
         slot_index_to_del = slot_index_to_add - self.slot_gap_default
diff --git a/tox.ini b/tox.ini
index 6a4482891809c3e435ec001e6f0c05e8fa86606d..d2f1dbcfd708f3535c057bf657e1cbbddf92bfdd 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,20 +1,9 @@
 [tox]
 minversion = 1.6.0
-envlist = coala,pep8,pre-commit
+envlist = docs,pre-commit
 # TODO: Include docs when it starts performing strict checks.
 skipsdist = true
 
-[testenv:coala]
-basepython = python3
-deps =
-    coala==0.11.0
-    coala-bears==0.11.0
-    pygments~=2.3.1
-    requests==2.15.1
-commands =
-    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
-    coala --non-interactive
-
 [testenv:docs]
 basepython = python3
 deps = -rdocs/requirements.txt
@@ -27,28 +16,3 @@ deps = pre-commit
 commands =
     pre-commit install
     pre-commit run --all-files
-
-[testenv:pep8]
-basepython = python2
-deps =
-    flake8~=3.5.0
-commands = flake8
-
-[flake8]
-show-source = True
-max-line-length = 120
-
-# # - Select E121, E123, E126, E226, E241, E242 and E704 which are turned OFF
-# #   by default but represent guidelines accepted by us.
-# # - Do not select E133 because it is incompatible with E123 which was
-# #   selected instead.
-# - It turns out that now all checks except E133 are enabled so the select
-#   can be simplified to be just "E,W". However a new version could change
-#   that (select E133 instead of E123) but that should be caught by the
-#   verify job.
-select = E,W
-ignore = E722 # as of aprox 10/25 some update/change has caused existing code to fail on E722
-exclude =
-    .git,
-    .tox,
-    docs/conf.py