Python linters
Ruff
- Ruff
- Docs
- Included in LazyVim python lang extra
- Container image i.e.:
registry.gitlab.com/pipeline-components/ruff:latest - pre-commit hook
Issues
Usage
Ignore rules: Error suppression, i.e.:
# Ignore E741 and F841.
i = 1 # noqa: E741, F841
# Ignore _all_ violations.
x = 1 # noqa
Pyright
- Included in LazyVim python lang extra,
but can be easily replaced with
basedpyright
Basedpyright
pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
- GitHub
- Docs
- Rejected: Support #noqa annotation
"The
# noqacomment is really meant for linters, Pyright doesn't perform any linting (code style) checks, only type checks."
File-level Type Controls: Globally ignore for whole file (insert at the top of file), i.e.:
# pyright: strict
# pyright: basic
# pyright: strict, reportPrivateUsage=false
# pyright: reportPrivateUsage=warning, reportOptionalCall=error
Line-level Diagnostic Suppression:
# pyright: ignore[reportUnknownArgumentType]
# pyright: reportAny=false,reportUnknownVariableType=false,reportUnknownMemberType=false
basedpyright issues
- I cannot find a way to both use
noqaandpyright:…for the same line
ty
An extremely fast Python type checker and language server, written in Rust. WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
# ty: ignore[unsupported-operator]
# ty: ignore[missing-argument, invalid-argument-type]
# type: ignore