From e4fa27e7cde6a917478416aefa375b57fb2cf413 Mon Sep 17 00:00:00 2001 From: Tom Collingwood Date: Thu, 13 Jan 2022 19:15:08 +0000 Subject: [PATCH] remove references to setup.cfg where inappropriate --- hooks/check_missing_requirements.py | 2 +- hooks/check_mypy_import_errors.py | 7 +++++-- hooks/check_pylint_import_errors.py | 16 +++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hooks/check_missing_requirements.py b/hooks/check_missing_requirements.py index 269b3da..094e5ef 100644 --- a/hooks/check_missing_requirements.py +++ b/hooks/check_missing_requirements.py @@ -1,5 +1,5 @@ """Checks to see if the package requirements are all present in the current -environment. +python environment. """ import subprocess import sys diff --git a/hooks/check_mypy_import_errors.py b/hooks/check_mypy_import_errors.py index 8a92bb8..efe4bdb 100644 --- a/hooks/check_mypy_import_errors.py +++ b/hooks/check_mypy_import_errors.py @@ -1,4 +1,4 @@ -"""Check and prevent mypy import errors.""" +"""Check and prevent mypy errors due to missing stubs.""" import sys import warnings from typing import Optional @@ -28,6 +28,9 @@ def _warning(message, *args, **kwargs): class CheckMypyImportErrors(Hook): # pylint: disable=too-few-public-methods """Hook to check whether mypy will raise import errors using the current project configuration, and fix the config file if necessary. + + This is configured to only run when changes to your `requirements.txt` or + `pyproject.toml` file are staged. """ def run(self) -> int: @@ -84,7 +87,7 @@ def run(self) -> int: print( " import errors found!\n", - f" adding new exceptions to setup.cfg: {', '.join(bad_imports)}", + f" adding new exceptions to config file: {', '.join(bad_imports)}", ) setup_file.add_mypy_ignore(bad_imports) setup_file.save_to_disk() diff --git a/hooks/check_pylint_import_errors.py b/hooks/check_pylint_import_errors.py index cbdf88c..435fa54 100644 --- a/hooks/check_pylint_import_errors.py +++ b/hooks/check_pylint_import_errors.py @@ -13,19 +13,21 @@ class CheckPylintImportErrors(Hook): # pylint: disable=too-few-public-methods """Hook to check whether pylint will raise import errors using the current project configuration, and fix the config file if necessary. + + This is configured to only run when changes to your `requirements.txt` or + `pyproject.toml` file are staged. """ def run(self) -> int: """ - Fixes pylint parameters in ``setup.cfg`` to prevent the CI pipeline giving - import errors during linting jobs, as not all packages provide pylint - support. This function should be run from within the top level repo - directory. + Fixes pylint parameters to prevent the CI pipeline giving import errors + during linting jobs, as not all packages provide pylint support. This + function should be run from within the top level repo directory. The function applies pylint to this repo, and greps the resultant output for any import error (E0401) messages. The function will then append - the bad package/module names to the ``[pylint]`` section of ``setup.cfg`` - to silence the error in future. + the bad package/module names to the relevant config section to silence + the error in future. This is a known bug with pylint and in this case, silencing the errors is the only fix to prevent CI job failure. @@ -75,7 +77,7 @@ def run(self) -> int: print( " Pylint import errors found!\n", - f" adding new exceptions to setup.cfg: {', '.join(bad_imports)}", + f" adding new exceptions to config file: {', '.join(bad_imports)}", ) # add bad modules to the pylint ignore section: