Migrate all Python linters to pre-commit 68/64968/1
authorThanh Ha <zxiiro@gmail.com>
Sat, 8 Aug 2020 19:03:29 +0000 (15:03 -0400)
committerThanh Ha <zxiiro@gmail.com>
Sat, 8 Aug 2020 19:03:29 +0000 (15:03 -0400)
Switch Python related Coala linters over to pre-commit hooks. We would
like to migrate off of the Coala platform as it has not had a release
in years.

Issue: RELENG-2642
Change-Id: Ic6f10682c2d982a7980f1abb58303c56a6086bc8
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
.coafile
.editorconfig
.pre-commit-config.yaml
docs/conf.py
setup.py
tests/test_simple.py

index 9f05225..3cab223 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -10,19 +10,6 @@ ignore = .tox/**,
 bears = WriteGoodLintBear
 files = docs/**.rst
 
-[all.Python]
-bears = BanditBear,
-    PEP8Bear,
-    PyCommentedCodeBear,
-    PyDocStyleBear,
-    PyFlakesBear,
-    PyImportSortBear
-files = docs_conf/**.py
-known_first_party_imports = lftools
-known_third_party_imports = pytest, six, sphinx_bootstrap_theme
-pydocstyle_ignore = D203, D213, D301
-max_line_length = 88
-
 [all.YAML]
 bears = YAMLLintBear
 files = docs_conf/**.yaml
index f77fecb..3b13db5 100644 (file)
@@ -15,4 +15,3 @@ max_line_legth = 88
 
 [*.yaml]
 indent_size = 4
-
index 9a6ec31..08519df 100644 (file)
@@ -1,4 +1,7 @@
 ---
+default_language_version:
+  python: python3
+
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v3.1.0
@@ -14,4 +17,21 @@ repos:
     rev: stable
     hooks:
     - id: black
-      language_version: python3
+
+  - repo: https://gitlab.com/pycqa/flake8
+    rev: 3.8.3
+    hooks:
+    - id: flake8
+      args: ['--max-line-length=88']
+
+  - repo: https://github.com/pycqa/bandit
+    rev: 1.6.2
+    hooks:
+    - id: bandit
+      # Bandit does not need to run on test code
+      exclude: tests/*
+
+  - repo: https://github.com/pycqa/pydocstyle
+    rev: 5.0.2
+    hooks:
+    - id: pydocstyle
index b5a9dd6..cc15e61 100644 (file)
@@ -9,6 +9,7 @@
 # which accompanies this distribution, and is available at
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
+"""Configuration for Sphinx."""
 
 import os
 import sys
@@ -16,9 +17,9 @@ import sys
 # Sys.path for RTD to resolve docs_conf package
 sys.path.insert(0, os.path.abspath(".."))
 
-from pbr.version import VersionInfo
+from pbr.version import VersionInfo  # noqa
 
-from docs_conf.conf import *
+from docs_conf.conf import *  # noqa
 
 version = str(VersionInfo("lfdocs-conf"))
 release = str(VersionInfo("lfdocs-conf"))
index c23a404..3ffa602 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,5 @@
-"""
-Setup for Docs Configuration
-"""
-from setuptools import setup, find_packages
+"""Setup for Docs Configuration."""
+from setuptools import setup
 
 
 with open("requirements.txt") as f:
index 3abcdbc..dfc5ff7 100644 (file)
@@ -9,9 +9,7 @@
 # which accompanies this distribution, and is available at
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
-"""
-Docs Conf Tests
-"""
+"""Docs Conf Tests."""
 import importlib
 import os
 import pytest
@@ -20,9 +18,7 @@ import sys
 
 @pytest.fixture()
 def config(tmpdir):
-    """
-    Create a basic conf.py and conf.cfg file for each test
-    """
+    """Create a basic conf.py and conf.cfg file for each test."""
     # Create the base 'conf.py'
     confpy = tmpdir.join("conf.py")
     confpy.write("from docs_conf.conf import *")
@@ -44,35 +40,25 @@ def config(tmpdir):
 
 
 def test_config(config):
-    """
-    Assert some basic assumption about how configurations are pulled in
-    """
+    """Assert some basic assumption about how configurations are pulled in."""
     assert config.project == "myproject"
     assert config.author == "Pythonista"
     # assert 'latex_documents' in dir(config)
 
 
 def test_defaults(config):
-    """
-    Test the defaults are set and the only thing required is a conf.py
-    w/import *
-    """
+    """Test the defaults are set and the only thing required is a conf.py w/import *."""
     # TODO
     assert True
 
 
 def test_project_override(config):
-    """
-    Test that setting sphinx.project pulls in the project specific
-    defaults
-    """
+    """Test that setting sphinx.project pulls in the project specific defaults."""
     # TODO
     assert True
 
 
 def test_theme_import(config):
-    """
-    Test setting sphinx.html_theme_module imports the correct theme
-    """
+    """Test setting sphinx.html_theme_module imports the correct theme."""
     # TODO
     pass