Skip to content

Import stricter Python lint tiers - #13

Merged
leynos merged 6 commits into
mainfrom
feat/import-ruff-pylint-rules
May 16, 2026
Merged

Import stricter Python lint tiers#13
leynos merged 6 commits into
mainfrom
feat/import-ruff-pylint-rules

Conversation

@lodyai

@lodyai lodyai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch imports the stricter Python lint policy from leynos/episodic so Stilyagi checks Python with Ruff first, then a focused Pylint pass through the pinned PyPy shim, before continuing through the existing Rust lint tiers. It also records that linting architecture in an ADR and expands the developer guide so maintainers can run, diagnose, and deliberately change the gate.

The branch is not linked to a roadmap task, issue, or execplan.

Review walkthrough

Validation

  • make fmt: passed
  • make lint: passed
  • make check-fmt: passed
  • make typecheck: passed
  • make test: passed; 59 Rust tests and 51 Python tests passed
  • make markdownlint: passed after the ADR and developer-guide update
  • make nixie: passed after the ADR and developer-guide update
  • mbake validate Makefile: passed

Notes

The imported RUF066 selector required refreshing the locked Ruff version because the previously locked Ruff release did not recognise that preview rule. The new Pylint tier also exposed a few existing Python and test clean-ups, which this branch resolves so the stricter gate starts green.

ADR 004 treats the Episodic lint policy as a deliberate baseline, not an automatic upstream subscription. Future lint-policy imports should be reviewed and gated rather than copied mechanically.

References

Import the Ruff selector set, banned deprecated `typing` APIs, and
focused Pylint message policy from `leynos/episodic`.

Run Pylint after Ruff through the pinned `pylint-pypy-shim` wrapper
under PyPy, then continue through the existing Rust lint tiers. Update
the Makefile contract tests and developer guide so the new lint path is
covered and documented.

Resolve the new lint findings in the existing Python code and tests, and
refresh the locked Ruff version so the imported preview rules are known.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @LodyAI[bot], you have reached your weekly rate limit of 2500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Standardise Makefile to use an uv wrapper and add PyPy-backed Pylint wiring; add Ruff and focused Pylint configuration to pyproject.toml; modernise Callable types to collections.abc; update protocol stubs and tests; apply broad documentation reflow and add ADR 004 describing the two‑tier lint architecture.

Changes

Linting toolchain and type modernisation

Layer / File(s) Summary
Makefile uv wrapper and pylint tooling
Makefile
Introduce UV, UV_ENV, UV_RUN wrapper variables; add PYLINT_* variables and PYLINT command using the PyPy shim; update .venv recipe to use wrappers; insert $(PYLINT) $(PYLINT_TARGETS) into the lint target.
Ruff and pylint configuration
pyproject.toml
Set Ruff target-version = "py314"; extend selects with TD and RUF066; add flake8-tidy-imports.banned-api rules banning deprecated typing.* APIs with replacement guidance; move and expand Pylint settings into tool.pylint (recursive analysis, design limits, messages control).
Type modernisation across codebase
python/stilyagi/smoke.py, tests/test_build_spine_units.py
Replace typing.Callable with collections.abc.Callable and adjust imports/aliases accordingly.
Protocol stubs and test validation
python/stilyagi/nlp/base.py, tests/test_package_skeleton_units.py, tests/test_build_spine_units.py
Change NlpProvider.provider_name to raise NotImplementedError; relax model.Document.regions assertion to falsy; remove inline # noqa in YAML load; change smoke stderr assertion to falsy; update test expectations for Makefile .venv recipe to expect $(UV) wrapper invocations.

Documentation updates for linting and examples

Layer / File(s) Summary
Developer guide: PyPy setup and linting workflow
docs/developers-guide.md, docs/adr-004-python-linting-architecture.md, docs/contents.md
Add ADR 004 and contents entry; document PyPy option and pinned pylint-pypy-shim usage; describe make lint execution order and uv invocation patterns; reflow tables and example formatting.
Execution plan documentation refinements
docs/execplans/1-2-3-makefile-and-ci-smoke-tests.md, docs/execplans/1-3-1-assemble-representative-fixtures.md
Clarify Actions smoke gate runs on Ubuntu, .venv-release-smoke installation, and running smoke proof from system temp dir; reflow repository layout and retrospective paragraphs.
Rules, RFC, and design documentation formatting
.rules/python-generators.md, docs/rfcs/0005-grammar-capability-and-syntactic-api-extensions.md, docs/stilyagi-design.md, docs/scripting-standards.md, docs/roadmap.md, docs/complexity-antipatterns-and-refactoring-strategies.md, docs/local-validation-of-github-actions-with-act-and-pytest.md
Reformat examples and inline stubs (collapse ... into single-line forms), adjust match-case example, rewrap snippets, and tweak blank lines and spacing for consistency across docs.

Sequence Diagram(s)

flowchart LR
  MakeLint["make lint"]
  PYLINT["PYLINT (uv tool run --python pypy + pylint-pypy-shim)"]
  RUFF["ruff check"]
  MakeLint --> PYLINT
  PYLINT --> RUFF
Loading

Possibly related PRs

  • leynos/episodic#87: Makefile lint target modifications with PyLint and PyPy shim variables align with this PR's Makefile lint wiring.
  • leynos/pylint-pypy-shim#6: Provides the PyPy-specific Pylint shim referenced and pinned by this PR.

Poem

🔧 Wrap uv and tune the linting seam,
Swap old typing for a modern scheme,
Tighten tests, make ADRs proclaim,
Reflow docs and wire the Pylint claim,
Small polish, steady progress — ship the dream.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error New Pylint linting in lint target and Pylint configuration lack substantive test coverage. No tests verify Pylint executes or new Makefile variables work. Add test_makefile_lint_target for $(PYLINT) invocation. Test new PYLINT Makefile variables. Validate Pylint rule enforcement.
Testing (Unit And Behavioural) ❓ Inconclusive Smoke tests verify type changes adequately. No tests verify new PYLINT execution in make lint or NlpProvider.provider_name raising NotImplementedError. Configuration changes validated implicitly. Add test_makefile_lint_target to verify PYLINT execution before ruff. Consider test for NlpProvider protocol stub.
✅ Passed checks (16 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Import stricter Python lint tiers' directly and clearly describes the main change: importing a stricter Python linting policy with two-tier architecture (Ruff then Pylint).
Description check ✅ Passed The description is comprehensive, related to the changeset, and explains the import of stricter Python lint policy, ADR 004, Makefile updates, and pyproject.toml configuration changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
User-Facing Documentation ✅ Passed PR introduces no user-facing changes. All modifications are development infrastructure (linting, Makefile) and internal refactoring. Public API and CLI behaviour remain unchanged.
Developer Documentation ✅ Passed ADR 004 documents decision. Developers guide section 6a documents tooling and variables. Roadmap item 1.2.3 complete. Execplan updated. No multi-language sync required.
Module-Level Documentation ✅ Passed All Python modules modified in this PR carry appropriate module-level docstrings. Each docstring clearly explains the module's purpose and utility.
Testing (Property / Proof) ✅ Passed This PR introduces only configuration and refactoring changes: linting rules, type alias migrations, and assertion updates. No new algorithmic invariants, axioms, or proof assumptions are introduced.
Testing (Compile-Time / Ui) ✅ Passed PR imports Python linting config without introducing compile-time code generation, compiler output behaviour, or new CLI/UI-adjacent output requiring snapshot or trybuild tests.
Unit Architecture ✅ Passed Changes preserve query/command separation, explicit fallibility, injectable dependencies, and coherent responsibilities. Configuration is declarative without hidden side-effects.
Domain Architecture ✅ Passed Domain boundaries remain clean. Changes modernise Python typing and error handling only. No infrastructure concerns leak into domain code.
Observability ✅ Passed Build-time tooling changes only. No production runtime observability changes, logging, metrics, tracing, or alerts introduced.
Security And Privacy ✅ Passed No secrets or credentials exposed. Pylint dependency pinned to public commit. Subprocess and encoding safety checks enabled. No injection or unsafe patterns detected.
Performance And Resource Use ✅ Passed No algorithmic regressions or unbounded resource growth. Config/doc changes only. Sequential lint execution, scoped targets. No cloning or allocation issues.
Concurrency And State ✅ Passed PR contains no concurrency, shared state, async execution, locks, or related concerns. Changes are configuration and documentation updates only.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/import-ruff-pylint-rules

Comment @coderabbitai help to get the list of available commands and usage tips.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
leynos marked this pull request as ready for review May 15, 2026 11:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/stilyagi-design.md`:
- Around line 805-806: The inline code span for `segments` is split across two
lines causing malformed backticks; update the Markdown so the entire inline code
list appears on a single line (e.g., change "It does not yet expose
`line_index`, `segments`," to keep the backticks around `segments` on the same
line) or move the backtick boundaries to a proper word boundary so `segments` is
fully enclosed; ensure the other items (`line_index`, `owner metadata`,
`canonical IR JSON`) remain formatted consistently and run mdformat-all /
markdownlint-cli2 to validate the fix.

In `@tests/test_build_spine_units.py`:
- Line 60: The test uses yaml.load(..., Loader=yaml.BaseLoader) which triggers
Ruff S506; either add "S506" to the per-file-ignores array for the test glob in
pyproject.toml (the "**/test_*.py" entry) so tests can use BaseLoader, or
restore a narrow inline suppression on the call to yaml.load using noqa for
S506; reference the yaml.load call and yaml.BaseLoader in
tests/test_build_spine_units.py and the "**/test_*.py" per-file-ignores entry in
pyproject.toml when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e57c5fa7-309e-4532-8466-529010ea50d9

📥 Commits

Reviewing files that changed from the base of the PR and between 52fb54c and 084dd90.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • .rules/python-generators.md
  • Makefile
  • docs/complexity-antipatterns-and-refactoring-strategies.md
  • docs/developers-guide.md
  • docs/execplans/1-2-3-makefile-and-ci-smoke-tests.md
  • docs/execplans/1-3-1-assemble-representative-fixtures.md
  • docs/local-validation-of-github-actions-with-act-and-pytest.md
  • docs/rfcs/0005-grammar-capability-and-syntactic-api-extensions.md
  • docs/roadmap.md
  • docs/scripting-standards.md
  • docs/stilyagi-design.md
  • pyproject.toml
  • python/stilyagi/nlp/base.py
  • python/stilyagi/smoke.py
  • tests/test_build_spine_units.py
  • tests/test_package_skeleton_units.py

Comment thread docs/stilyagi-design.md Outdated
Comment thread tests/test_build_spine_units.py
Add ADR 004 for the Ruff-first, focused-Pylint-second linting
architecture and record the Makefile execution model behind `make lint`.

Expand the developer guide with the lint tiers, Makefile variables,
Episodic policy baseline, and `pyproject.toml` configuration sections so
maintainers can change or diagnose the lint gate deliberately.
codescene-delta-analysis[bot]

This comment was marked as outdated.

Allow checked-in YAML fixture parsing in tests through Ruff per-file
ignores, matching the test-only scope of the existing workflow parser.

Rewrite the design note payload wording so Markdown formatting no longer
splits inline code spans across lines.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/developers-guide.md`:
- Line 612: In the documentation line containing the phrase "bans broad `from`
imports for modules whose aliases are standardised", replace the British
spelling "standardised" with the en-GB-oxendict form "standardized" so the
sentence reads "...whose aliases are standardized"; update any other occurrences
of "standardised" in docs/developers-guide.md to "standardized" to comply with
the en-GB-oxendict -ize guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5139020a-cc5f-47f4-9f73-77559a199b34

📥 Commits

Reviewing files that changed from the base of the PR and between 084dd90 and 46a61d2.

📒 Files selected for processing (5)
  • docs/adr-004-python-linting-architecture.md
  • docs/contents.md
  • docs/developers-guide.md
  • docs/stilyagi-design.md
  • pyproject.toml

Comment thread docs/developers-guide.md Outdated
Replace the lint guide wording with the Oxford spelling `standardized`.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added the Roadmap label May 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/developers-guide.md`:
- Around line 179-184: Add a short caption line immediately above each of the
two Markdown tables so they comply with the "Caption every table" rule; locate
the first table that documents SHARED_MARKDOWN_FIXTURE_PATH, repository_root,
corpus_fixture_path, and read_corpus_fixture and insert a one-sentence caption
directly before the table, and do the same for the other table referenced around
the 572-582 range—ensure captions are brief (e.g., "Table: Repository fixture
utilities and signatures") and placed on their own line immediately preceding
each table block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 66bb2703-6402-413b-bdfe-d2a459784cf9

📥 Commits

Reviewing files that changed from the base of the PR and between 46a61d2 and e941c03.

📒 Files selected for processing (1)
  • docs/developers-guide.md

Comment thread docs/developers-guide.md
Reorder the focused Pylint allowlist by diagnostic purpose so logging,
pattern matching, control flow, collections, runtime hazards, text
hygiene, mutation, and complexity checks are easier to review.
codescene-delta-analysis[bot]

This comment was marked as outdated.

Add short captions before the fixture utility and lint variable tables so
the developer guide follows the documentation table-caption rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant