Check Pylint Import Errors

Check and prevent pylint import errors.

class hooks.check_pylint_import_errors.CheckPylintImportErrors(argv: Optional[Sequence[str]] = None)

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.

run() int

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 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.

Raises

Exception – if pylint fails to run

hooks.check_pylint_import_errors.main()

Hook entry point