Lint all Python files with ruff#2138
Open
bboe wants to merge 25 commits into
Open
Conversation
Replace the source-only `include` (`praw/**.py`, a malformed glob) with the ruff-idiomatic `["*.py"]` so tests, examples, maintenance scripts, and docs are linted too, relying on ruff's default `exclude` and gitignore handling to keep build artifacts out. Drop the redundant `files:` filter on the ruff pre-commit hook so the hook and `ruff check .` lint the same set. Non-library code (tests, `tools/`, `docs/examples/`, `pre_push.py`, the Sphinx config) is not held to the package source's docstring/annotation/style strictness, so each group gets a curated per-file-ignore — most notably tests, where the dominant violation was PLR6301 (no-self-use) firing on every pytest method. Apply ruff's safe autofixes to the newly-covered files.
- Fix the mis-anchored `name-tests-test` `files` regex (the `|` split it into two half-anchored alternatives); use `^tests/(integration|unit)/.*\.py$`. - Run docstrfmt with `require_serial` for parity with prawcore. - Enforce `--fail-under=100` in the coverage tox env.
Adopt ruff's formatter (already used by prawcore/asyncprawcore) so Python code formatting is enforced. Reformat the codebase under `line-length = 120`; all changes are cosmetic and behavior-preserving, and ruff-format, docstrfmt, and auto-walrus are mutually stable.
Replace the explicit `select` list with `select = ["ALL"]` so the linter is opt-out rather than opt-in, matching prawcore/asyncprawcore. Because `preview = true`, ALL also pulls in preview rules; ignore the ones that don't fit praw's conventions: copyright headers (CPY001), pydoclint-style return/yield/ raise documentation (DOC201/DOC402/DOC501), the formatter conflicts (COM812, ISC001), the complexity metric (C901), and the FURB101/PERF micro-optimizations (left as follow-ups). Safe autofixes applied a few simplifications (e.g. `x if x else ""` -> `x or ""`).
Fix the PERF/FURB101 violations that were ignored as follow-ups when select= ["ALL"] was adopted, and drop those rules from the ignore list: use list.extend/ dict.update/dict comprehensions (PERF401/PERF403), iterate dict values directly (PERF102), and read files via Path.read_text/read_bytes (FURB101). Only the genuinely-permanent ignores remain (C901 complexity, PERF203 per-iteration try/except).
hatchling does not derive the package description from the module docstring, so the built distributions shipped with an empty Summary. Declare it statically.
Bump the pinned ruff pre-commit hook to v0.15.17 and raise the development tool version floors (ruff, pyright, pytest, coverage, vcrpy, tox-uv) to their latest releases, refreshing uv.lock to match.
MANIFEST.in is a setuptools-only mechanism; the hatchling build backend ignores it entirely (it was even being shipped into the sdist as ordinary content). The sdist contents are unchanged by its removal.
Prevents the untracked agent-config directory from leaking into a sdist built from a dirty working tree.
Add the @abstract exclusion so [tool.coverage.report] matches the other projects.
Use Read the Docs' canonical configuration filename, matching prawcore and async-prawcore.
Switch the mixed-line-ending hook from --fix=no (check only) to --fix=lf so it actively normalizes all text files to LF.
Use a single shared ignore list (the union of the previous per-project entries) so all four projects ignore the same set of editor, tooling, and build artifacts.
Add [tool.pytest.ini_options] with testpaths = "tests" so a bare pytest run only collects from the tests directory, matching the other projects.
Add [tool.tomlsort] sort_table_keys = true so the toml-sort hook sorts the keys within every table, not just the tables themselves. The files were already key-sorted, so this only makes the enforcement explicit and keeps it consistent going forward; order-sensitive arrays (tox commands, ignore lists) are left untouched.
Enable [tool.tomlsort] sort_inline_tables so the author and maintainer inline-table keys are sorted.
- Delete the vestigial pre_push.py (superseded by tox) and the unused profile_tests.sh, and point the CONTRIBUTING docs at `uv run tox`. - Normalize dependency version specifier spacing in pyproject.toml. - Refresh uv.lock.
prawcore is making Requestor's parameters keyword-only; pass them by name so the call keeps working.
prawcore is making authorize_url's parameters keyword-only; pass them by name so the call keeps working.
9f62e67 to
84ceed3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches ruff's
includeto the idiomatic["*.py"]so the entire repository is linted — previously onlypraw/source was (via a malformedpraw/**.pyglob), leaving tests,tools/,docs/, andpre_push.pyunlinted.Why
include = ["praw/**.py"]scoped ruff to package source only; tests/tooling were never linted. Bare*.pyis ruff's own default idiom and relies on the defaultexclude(build/dist/.tox/.venv/…) + gitignore to skip artifacts.Changes
[tool.ruff] include→["*.py"]files: ^(praw/.*.py)$filter on the ruff pre-commit hooktools/,docs/examples/,pre_push.py,docs/conf.py). The package source is already clean and unaffected. The dominant test violation wasPLR6301(no-self-use), a preview rule that fires on every class-based pytest method — relaxed rather than churning the suite into staticmethods.open()→Path().open(),dict.fromkeys, etc. — all behavior-preserving)Verification
ruff check .clean; full test suite green (1002 passed, 1 skipped).