From 01743bfbdd345eaa5f83341ad939b8f51faeadac Mon Sep 17 00:00:00 2001
From: Reid 'arrdem' McKenzie <me@arrdem.com>
Date: Sun, 29 Aug 2021 22:35:00 -0600
Subject: [PATCH] More tooling

---
 setup.cfg                     | 25 ++++++++++++++-----------
 tools/flake8/BUILD            |  7 +++++++
 tools/flake8/__main__.py      |  5 +++++
 tools/fmt.sh                  |  2 +-
 tools/lint.sh                 |  2 +-
 tools/python/requirements.txt |  3 +++
 tools/sphinx/__main__.py      |  1 -
 7 files changed, 31 insertions(+), 14 deletions(-)
 create mode 100644 tools/flake8/BUILD
 create mode 100644 tools/flake8/__main__.py

diff --git a/setup.cfg b/setup.cfg
index 6f36468..66b0f32 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,21 +1,24 @@
 [isort]
-line_length=100
-indent=2
+line_length = 100
+indent = 4
 # 1/Vertical
-multi_line_output=3
-lines_after_imports=2
-default_section=THIRDPARTY
-known_localfolder=datalog
-sections=FUTURE,STDLIB,LOCALFOLDER,THIRDPARTY
-force_sort_within_sections=1
-force_alphabetical_sort_within_sections=1
-combine_as_imports=1
+multi_line_output = 3
+lines_after_imports = 2
+default_section = THIRDPARTY
+known_localfolder = datalog
+sections = FUTURE,STDLIB,LOCALFOLDER,THIRDPARTY
+force_sort_within_sections = 1
+force_alphabetical_sort_within_sections = 1
+combine_as_imports = 1
 
 [distutils]
 index-servers = pypi
 
 [reqman]
-shitlist=pip,pkg_resources,setuptools
+shitlist = pip,pkg_resources,setuptools
+
+[flake8]
+extend-ignore = E203,E501,F405,F403,E731
 
 [pypi]
 repository = https://pypi.python.org/pypi
diff --git a/tools/flake8/BUILD b/tools/flake8/BUILD
new file mode 100644
index 0000000..f522a80
--- /dev/null
+++ b/tools/flake8/BUILD
@@ -0,0 +1,7 @@
+py_binary(
+    name = "flake8",
+    main = "__main__.py",
+    deps = [
+        py_requirement("flake8"),
+    ],
+)
diff --git a/tools/flake8/__main__.py b/tools/flake8/__main__.py
new file mode 100644
index 0000000..dfc8ba6
--- /dev/null
+++ b/tools/flake8/__main__.py
@@ -0,0 +1,5 @@
+from flake8.main import cli
+
+
+if __name__ == "__main__":
+    cli.main()
diff --git a/tools/fmt.sh b/tools/fmt.sh
index bb5fc35..6e6640f 100755
--- a/tools/fmt.sh
+++ b/tools/fmt.sh
@@ -14,7 +14,7 @@ function brl() {
     return "$?"
 }
 
-brl tools/autoflake -ir "${DIRS[@]}"
+brl tools/autoflake --remove-all-unused-imports -ir "${DIRS[@]}"
 brl tools/isort     "${DIRS[@]}"
 brl tools/unify     --quote '"' -ir "${DIRS[@]}"
 brl projects/reqman clean tools/python/requirements.txt
diff --git a/tools/lint.sh b/tools/lint.sh
index 768283f..ed417d3 100755
--- a/tools/lint.sh
+++ b/tools/lint.sh
@@ -13,7 +13,7 @@ function brl() {
     return "$?"
 }
 
-brl tools/autoflake -r "${DIRS[@]}"
+brl tools/flake8 "${DIRS[@]}"
 brl tools/isort --check "${DIRS[@]}"
 brl tools/unify --quote '"' -cr "${DIRS[@]}"
 brl tools/reqman lint tools/python/requirements.txt
diff --git a/tools/python/requirements.txt b/tools/python/requirements.txt
index 8983238..59124ee 100644
--- a/tools/python/requirements.txt
+++ b/tools/python/requirements.txt
@@ -11,6 +11,7 @@ click==7.1.2
 commonmark==0.9.1
 coverage==5.5
 docutils==0.17
+flake8==3.9.2
 Flask==2.0.1
 hypothesis==6.14.5
 idna==2.10
@@ -29,6 +30,7 @@ lxml==4.6.3
 m2r==0.2.1
 Markdown==3.3.4
 MarkupSafe==2.0.1
+mccabe==0.6.1
 meraki==1.7.2
 mirakuru==2.4.1
 mistune==0.8.4
@@ -47,6 +49,7 @@ psutil==5.8.0
 psycopg2==2.9.1
 pudb==2020.1
 py==1.10.0
+pycodestyle==2.7.0
 pyflakes==2.3.1
 Pygments==2.8.1
 pyparsing==2.4.7
diff --git a/tools/sphinx/__main__.py b/tools/sphinx/__main__.py
index c310f99..d59f4ef 100644
--- a/tools/sphinx/__main__.py
+++ b/tools/sphinx/__main__.py
@@ -17,7 +17,6 @@ import sys
 import click
 import livereload
 from sphinx.application import Sphinx
-from sphinx.cmd.build import main as build
 from sphinx.cmd.quickstart import main as new
 from sphinx.ext.apidoc import main as apidoc
 from sphinx.ext.autosummary.generate import main as autosummary