镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

🔧 build(lint): adopt simplint 0.8.0 - #308

Merged
gaborbernat merged 11 commits into
pytest-dev:mainfrom
gaborbernat:simplint
Nov 8, 2026
Merged

gaborbernat merged 11 commits into
pytest-dev:mainfrom
gaborbernat:simplint

Conversation

@gaborbernat

Copy link
Copy Markdown
Collaborator

simplint checks conventions that Ruff cannot, such as reST docstrings on the public API, Final constants, frozen keyword-only dataclasses, definition order, and reasons on suppressions. This change runs it in pre-commit at v0.8.0 and edits the code so simplint reports nothing, which makes these rules hold on every change instead of only in review. Users of the plugin see no change to the names or signatures they import.

Lint configuration

Ruff's undocumented-* rules are off, because simplint's undocumented-public-api rule (SMP903) asks for docstrings only on the names the package exports. Hooks also get explicit prek priority tiers. prek runs lower numbers first and runs hooks that share a number concurrently, so the tiers keep hooks that write the same file apart.

Module layout

Each helper now follows the first function that calls it. The plugin hooks and Entry are listed in __all__, since simplint treats the public names of a plugin module as its API. The TOML loader returns a named result instead of a three-item tuple, and the env-file loader is split so each function does one job. The loaders record the actions they take, and only the verbose header reads that record.

Typing and suppressions

Module constants and the TOML value alias have explicit types. Each suppression comment says why the rule is bypassed, and the internal TOML result is a frozen, keyword-only dataclass. Repeated checks are parametrized with named ids, and patching goes through the mocker fixture from pytest-mock, which the project already depends on.

Importable names

The hooks and Entry keep their signatures. An autofix had made Entry frozen and keyword-only, which broke positional construction, so that change was reverted. The names that moved or changed are all private: _env_actions_key is now _ENV_ACTIONS_KEY, _apply_entries is folded into the load hook, _apply_env_files requires actions and skip_if_set, and _load_toml_config returns a _TomlConfig instead of a tuple.

Hook source

The hook pins the v0.8.0 release of simplint through simplint-pre-commit.

Ruff's D1xx rules and simplint's function-docstring disagree on the
docstrings of internal functions, so simplint refuses to run until the
undocumented-public-* rules are ignored; SMP903 documents the public API.
Applied with simplint check --fix --unsafe-fixes, then the formatters through prek.
simplint requires a type on Final and a reason after every suppression code, so the reason states why the rule is bypassed.
The TOML loader returned a three-field tuple, and the env-file loader sat
past the complexity limit. Actions are now always collected, so the loaders
drop their None checks; only the verbose header reads them.
The project depends on pytest-mock, so tests use its fixture instead of unittest.mock.
Each case lists the files it writes, so the tests no longer branch on which files exist. Rows that were unnamed get ids, and the discovery tests take the section and fallback name from the row.
Each helper follows the function that first calls it, as simplint's definition-before-use rule reads it. The TOML classes and the type alias move up with the constant.
simplint treats the public names of a pytest11 module as API, so the hooks and Entry are listed.
The expected PYTHONPATH and PYTHONDONTWRITEBYTECODE values came from the outer process. The test now clears the environment and passes each case its values, so every expectation is a constant.
The autofix made Entry frozen and keyword-only, which broke code that builds it
with positional fields. Entry is in __all__ now, so its signature is public and
goes back to the original plain dataclass; simplint reports nothing for it.
@gaborbernat gaborbernat added enhancement New feature or request skip news PR does not need a changelog entry labels Nov 8, 2026
@gaborbernat
gaborbernat merged commit 640b2b9 into pytest-dev:main Nov 8, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request skip news PR does not need a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant