Skip to content

Python

gspot checks Python with Ruff for lint and format, basedpyright, import-linter, pydoclint, and deptry, plus built-in checks. These checks run for the python configuration:

CheckStageWhat it does
python/ruffcommitLints every Python file with the Ruff rules for the level, security rules included.
python/ruff-formatcommitChecks the layout of every Python file against the Ruff formatter.
python/basedpyrightpushType checks the project. At level all, it also requires annotations.
python/import-lintercommitRuns project import contracts from setup.cfg, .importlinter, or pyproject.toml.
python/pydoclintcommitChecks that each docstring names the arguments, return value, and exceptions of its function.
python/deptrypushCompares the imports of the project with the dependencies it declares: missing, unused, and transitive ones.
python/pip-installscommitChecks that pyproject.toml lists every dependency, with no hand-kept requirements file and no pip install.
python/placeholder-docstringscommitFinds docstrings that hold a placeholder word, or the name of the function again.

Install gspot with mise, as the Quickstart shows for a repository without package.json. Use uv for your project. basedpyright and pytest read the .venv of the project, so sync it before you run the checks:

uv sync

pydoclint takes its docstring style from the first source that sets one:

  1. A [tool.pydoclint] style in pyproject.toml.
  2. The pydocstyle convention in the Ruff options of the project.
  3. tools.ruff.docstring_convention, when it equals google or numpy.
  4. Google or NumPy sections that gspot finds in your docstrings.

Otherwise, pydoclint uses its default.

Tests and coverage covers pytest.