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

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 = ['py313']

[tool.pylint]
disable = [
  "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
]
max-line-length = 120
ignore = [".git", "__pycache__"]
j = 0
reports = true

[tool.isort]
line_length = 120
profile = "black"
force_grid_wrap = 2
multi_line_output = 3

[tool.mypy]
exclude = "(.git|__pycache__)"

[tool.pydocstyle]
convention = "numpy"

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

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

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