Linter

The galois library uses pylint for static analysis and code formatting.

Install

First, pylint needs to be installed on your system. Easily install it by installing the development dependencies.

$ python3 -m pip install .[dev]

Configuration

Various nuisance pylint warnings are added to an ignore list in pyproject.toml.

pyproject.toml
[tool.pylint]
ignore-paths = [
    "src/galois/_version.py",
]
disable = [
    "comparison-with-callable",  # pylint doesn't understand metaclass properties
    "fixme",
    "global-statement",
    "invalid-name",
    "missing-function-docstring",
    "protected-access",
    "too-many-ancestors",
    "too-many-arguments",
    "too-many-branches",
    "too-many-instance-attributes",
    "too-many-lines",
    "too-many-locals",
    "unneeded-not",
]
min-similarity-lines = 100
max-line-length = 140

[tool.black]
line-length = 140
exclude = '''
/(
      build
)/
    | src/galois/_version.py
'''
# NOTE: You must use single-quoted strings in TOML for regular expressions. It's the equivalent of r-strings in Python.
# For some reason, this exclude line doesn't work when on a single line.

[tool.isort]
profile = "black"

Run from the command line

Run the linter manually from the command line.

$ python3 -m pylint src/galois/

Run from VS Code

Included is a VS Code configuration file .vscode/settings.json. This instructs VS Code about how to invoke pylint. VS Code will run the linter as you view and edit files.


Last update: Dec 11, 2022