Home | Ubuntu/Mint | Arch/Manjaro | ssh/gpg | texlive | python | git | steam

Python

linter

For linter documentation see:

More on type hints: docs.python.org/3/library/typing.html↗ and mypy.readthedocs.io-cheat-sheet↗.
For a comparison of some linters see linters↗. To configure the linters, create a setup.cfg file containing
[isort]
line_length = 120
profile = black
force_grid_wrap = 2
multi_line_output = 3

[flake8]
# E704 multiple statements on one line (def)
# W503 line break before binary operator
ignore = E704,W503,
max-line-length = 120
exclude = .git __pycache__
statistics = True
select = C,E,F,W,B,B9

[pycodestyle]
# E704 multiple statements on one line (def)
# W503 line break before binary operator
ignore = E704,W503,
max-line-length = 120
exclude = .git __pycache__
statistics = True

[pydocstyle]
convention = numpy

[mypy]
exclude = (.git|__pycache__)

and a pylintrc file containing
[pylint]
# C0302 too many lines
# C0325 superfluous-parens
# R0801 duplicate-code
# R0912 too-many-branches
# R0913 too-many-arguments
# R0914 too-many-locals
# R0915 too-many-statements
disable = C0302,C0325,R0801,R0912,R0913,R0914,R0915,
max-line-length = 120
ignore = .git __pycache__
j = 0
reports = yes

and a pyproject.toml file containing
[tool.autopep8]
max_line_length = 120
in-place = true
recursive = true
aggressive = 3

[tool.bandit]
exclude_dirs = [""]
skips = ["B404", "B603"]  # https://github.com/PyCQA/bandit/issues/333

[tool.black]
line-length = 120
target-version = ['py311']

[tool.pyright]
# exclude = [""]

[tool.ruff]
line-length = 120
target-version = "py311"

[tool.ruff.lint]
select = ["ALL"]
ignore = [
  "COM812", "C901",
  "D203", "D212", "D413",
  "ERA001",
  "FBT001", "FBT002",
  "FIX002",
  "PLR0912", "PLR0913", "PLR0915", "PLR2004",
  "PTH123",
  "S108", "S501", "S507",
  "TD002", "TD003", "TD004",
  "TRY003",
]

To include them as pre-commit hooks, see git.