Skip to content

Commit

Permalink
remove references to setup.cfg where inappropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
TColl committed Jan 13, 2022
1 parent a7c3610 commit e4fa27e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hooks/check_missing_requirements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Checks to see if the package requirements are all present in the current
environment.
python environment.
"""
import subprocess
import sys
Expand Down
7 changes: 5 additions & 2 deletions hooks/check_mypy_import_errors.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 9 additions & 7 deletions hooks/check_pylint_import_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e4fa27e

Please sign in to comment.