Skip to content

feat: support ruff 0.16+, refresh all predefined configs, and handle codeless rules - #209

Merged
Kilo59 merged 12 commits into
mainfrom
chore/audit-kitchen-sink-bump-ruff-0.16.5
Aug 29, 2026
Merged

feat: support ruff 0.16+, refresh all predefined configs, and handle codeless rules#209
Kilo59 merged 12 commits into
mainfrom
chore/audit-kitchen-sink-bump-ruff-0.16.5

Conversation

@Kilo59

@Kilo59 Kilo59 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Adds support for Ruff 0.16+: refreshes all predefined configurations for v0.16.5, updates the engine and TUI to handle rules that have no short code (codeless/category rules introduced in 0.16.x), and strictly enforces the ban on unittest.mock across the codebase.

Key Changes

Ruff 0.16+ Dev Tooling Update

  • Updated ruff dev dependency and astral-sh/ruff-pre-commit rev to v0.16.5.
  • Updated uv.lock and AGENTS.md.

Predefined Config Audits

  • Kitchen Sink (configs/kitchen-sink/ruff.toml):
    • Updated header from Ruff v0.15.5Ruff v0.16.5.
    • Added new FAST (FastAPI) rule category with doc link.
    • Fixed missing INT (flake8-gettext) entry and corrected the ARG doc link.
    • Enabled "CPY" (flake8-copyright) now that CPY001 is stable.
    • Updated [lint.pep8-naming] to include Pydantic v2 decorators.
    • Added reference sections for [lint.flake8-copyright], [lint.flake8-gettext], and [format].nested-string-quote-style.
  • FastAPI (configs/fastapi/ruff.toml): Added "FAST" to [lint].select.
  • Data Science & Engineering (configs/data-science-engineering/ruff.toml): Refreshed for current Ruff conventions.
  • Docs (docs/pre-defined-configs.md): Updated rule count to "over 900 rules".

Codeless/Category Rule Compatibility (src/ruff_sync/)

Rules introduced in Ruff 0.16.x (e.g. pytest-fixture-autouse) can lack a short code and match only by category or name. Updated system.py, validation.py, and the TUI layer (tui/types_.py, tui/screens.py, tui/widgets.py, tui/app.py) to handle these rules safely throughout rule evaluation, search, inspection, and rendering.

  • Updated docstring and examples for get_ruff_rule_markdown() to reflect support for rule names as well as rule codes.

Import Ban Enforcement (unittest.mock)

  • Enforced project-wide ban on unittest.mock via flake8-tidy-imports.banned-api (TID251) and flake8-import-conventions.banned-from (ICN003) in pyproject.toml and tests/ruff.toml.
  • Removed TID251 exclusion from tests/* per-file-ignores so that banned mock imports are actively blocked across all tests.
  • Replaced all legacy unittest.mock / patch usage in tests/test_system.py and tests/tui/test_tui.py with pytest.MonkeyPatch and lightweight test stubs/spies (FakeProcess, SubprocessSpy).

Tests

  • tests/test_predefined_configs.py (new): Validates all predefined configs parse correctly and asserts expected preset settings.
  • tests/test_rule_logic.py: Expanded with codeless rule behavior coverage.
  • tests/tui/test_tui.py, tests/tui/test_tui_types.py: Extended TUI coverage for codeless rules.
  • tests/test_system.py: Rebuilt without unittest.mock, adding full test coverage for rule markdown by name/code, linters, and config fetching.

Verification

  • uv run invoke lint — 0 errors
  • uv run invoke fmt — clean
  • uv run invoke type-check — 55 files, mypy strict
  • uv run pytest -vv — 435 passed, 1 xfailed

Summary by Sourcery

Upgrade Ruff support to 0.16.5, make codeless rules work throughout the application, refresh predefined configurations, and enforce mock-import restrictions.

New Features:

  • Support Ruff rules identified by names or categories when they do not have short codes, including evaluation, inspection, search, and TUI rendering.
  • Add Ruff 0.16.5-compatible predefined configurations for FastAPI, data science and engineering, and comprehensive rule coverage.

Bug Fixes:

  • Prevent codeless Ruff rules from causing failures during validation and TUI interactions.
  • Enforce the project-wide prohibition on unittest.mock imports.

Enhancements:

  • Refresh predefined configuration settings and documentation for current Ruff conventions and expanded rule coverage.

Build:

  • Upgrade the Ruff development dependency and pre-commit hook to version 0.16.5.
  • Increment the project development version to 0.1.9.dev1.

Documentation:

  • Update predefined configuration documentation to reflect coverage of more than 900 Ruff rules.

Tests:

  • Add validation tests for all predefined configurations and expanded coverage for codeless rules and TUI behavior.
  • Replace unittest.mock-based tests with monkeypatching and lightweight test doubles.

@sourcery-ai

sourcery-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR upgrades Ruff support to 0.16.5, refreshes and validates all predefined configurations, and propagates optional rule metadata through rule evaluation and the TUI so codeless/category rules can be selected, grouped, inspected, searched, and rendered safely.

Flow diagram for codeless Ruff rule handling

flowchart TD
    A[Ruff rule metadata] --> B[compute_effective_rules]
    B --> C{Match code, name, or category}
    C --> D[Rule status]
    D --> E[Search and inspection]
    D --> F[Group by linter or category]
    F --> G[Render rule with fallback identifier]
Loading

File-Level Changes

Change Details Files
Updated Ruff tooling and lockfile to the 0.16.5 release.
  • Raised the development Ruff requirement and pre-commit revision.
  • Regenerated dependency locking metadata and updated contributor tooling documentation.
.pre-commit-config.yaml
pyproject.toml
uv.lock
AGENTS.md
Refreshed predefined Ruff configurations and added validation coverage for their structure and compatibility.
  • Reworked the Data Science & Engineering preset with current lint, format, notebook, and domain-specific settings.
  • Expanded FastAPI and Kitchen Sink rule selections, including FAST, CPY, and INT, and updated Ruff 0.16.5 references and options.
  • Added tests that parse each preset, validate it with Ruff in strict mode, and assert key preset-specific settings.
  • Updated documentation to reflect the expanded rule inventory.
configs/data-science-engineering/ruff.toml
configs/fastapi/ruff.toml
configs/kitchen-sink/ruff.toml
docs/pre-defined-configs.md
tests/test_predefined_configs.py
Made rule evaluation and validation robust to Ruff rules without short codes.
  • Treat rule code, name, and category as alternative selectors for effective-rule status.
  • Allow deprecated-rule filtering to skip codeless entries safely.
  • Expand the rule type to represent optional code, linter, and category fields.
src/ruff_sync/system.py
src/ruff_sync/types_.py
src/ruff_sync/validation.py
tests/test_rule_logic.py
Updated TUI identity, grouping, search, inspection, and rendering to support codeless and category rules.
  • Use rule names as stable identifiers and documentation targets when codes are absent.
  • Match rules to linters through linter names, code prefixes, categories, or rule-name prefixes.
  • Render fallback values for missing code and linter fields and search by available identifiers.
  • Added focused tests for codeless nodes, linter matching, active-state detection, and table rendering.
src/ruff_sync/tui/types_.py
src/ruff_sync/tui/screens.py
src/ruff_sync/tui/widgets.py
src/ruff_sync/tui/app.py
tests/tui/test_tui.py
tests/tui/test_tui_types.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/ruff_sync/tui/types_.py" line_range="237-238" />
<code_context>
     prefix = linter.get("prefix")
     if prefix and any(
-        r["code"].startswith(prefix) and r["status"] != "Disabled" for r in effective_rules
+        (r.get("code") or "").startswith(prefix) and r.get("status") != "Disabled"
+        for r in effective_rules
     ):
         return True
</code_context>
<issue_to_address>
**issue (broader_impact):** Codeless rules are never considered when activating or populating a linter group: `_is_linter_active` only matches non-empty rule codes, and the linter table still filters on `r["linter"] == linter_name`. A Ruff 0.16.5 rule such as `pytest-fixture-autouse` therefore disappears from its linter view, even when its name or category is selected and its status is Enabled.

**Triggers:** When a codeless Ruff rule has no code and no matching linter string, as represented by the new compatibility test data.

**Suggested fix:** Match linter groups using the rule name/category when the code or linter field is absent, and use the same fallback in the table filter.
</issue_to_address>

### Comment 2
<location path="src/ruff_sync/tui/app.py" line_range="221" />
<code_context>
         """
         # Fetch metadata for enrichment
-        rule_data = next((r for r in self.effective_rules if r["code"] == rule_code), None)
+        rule_data = next(
+            (
+                r
+                for r in self.effective_rules
+                if r.get("code") == rule_code or r.get("name") == rule_code
+            ),
+            None,
</code_context>
<issue_to_address>
**nitpick:** The `_inspect_rule` implementation now accepts either a rule code or a rule name, but its docstring still says that `rule_code` is the Ruff rule code and gives only a code-based contract. The documented callable contract is therefore false for the newly supported codeless-rule path.

**Triggers:** When the omnibox or a table row selects a codeless rule by name.

**Suggested fix:** Update the parameter documentation to state that the argument may be either a Ruff rule code or a rule name.

```suggestion
            rule_code: A Ruff rule code or rule name to inspect.
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/ruff_sync/tui/types_.py:238


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/ruff_sync/tui/types_.py Outdated
Comment thread src/ruff_sync/tui/app.py Outdated

@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.

Sourcery assessment

Approved.

@codspeed-hq

codspeed-hq Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 15 untouched benchmarks


Comparing chore/audit-kitchen-sink-bump-ruff-0.16.5 (e0a68be) with main (83bb13e)

Open in CodSpeed

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.28%. Comparing base (83bb13e) to head (e0a68be).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #209      +/-   ##
==========================================
+ Coverage   94.21%   94.28%   +0.07%     
==========================================
  Files          10       11       +1     
  Lines        1590     1610      +20     
==========================================
+ Hits         1498     1518      +20     
  Misses         92       92              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kilo59

Kilo59 commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

@sourcery-ai review

@Kilo59 Kilo59 added bug Something isn't working config-recipe Domain-specific configuration examples and recipes labels Aug 29, 2026

@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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Kilo59 Kilo59 changed the title feat(configs): audit kitchen sink configs and bump ruff to 0.16.5 feat: bump ruff to 0.16.5, refresh all predefined configs, and handle codeless rules Aug 29, 2026
@Kilo59 Kilo59 changed the title feat: bump ruff to 0.16.5, refresh all predefined configs, and handle codeless rules feat: support ruff 0.16+, refresh all predefined configs, and handle codeless rules Aug 29, 2026
@Kilo59

Kilo59 commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

@sourcery-ai review

@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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/ruff_sync/tui/app.py" line_range="224-229" />
<code_context>
         """
         # Fetch metadata for enrichment
-        rule_data = next((r for r in self.effective_rules if r["code"] == rule_code), None)
+        rule_data = next(
+            (
+                r
+                for r in self.effective_rules
+                if r.get("code") == rule_code or r.get("name") == rule_code
+            ),
+            None,
+        )
</code_context>
<issue_to_address>
**nitpick:** Codeless rules are now passed to `get_ruff_rule_markdown` by name, but its docstring still documents the parameter as a Ruff rule code and gives only a code-based example. This misstates the supported input contract for callers and maintainers.

**Triggers:** When inspecting a codeless rule from the TUI.

**Suggested fix:** Update the `get_ruff_rule_markdown` docstring to state that the argument accepts either a Ruff rule code or rule name, and update the example.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/ruff_sync/tui/app.py
@Kilo59
Kilo59 enabled auto-merge (squash) August 29, 2026 17:47
@github-actions

Copy link
Copy Markdown
Contributor
╒═══════════════╤══════════════╤═════════════════╤═════════════════╤════════════╕
│ File          │ Cyclomatic   │ Maintainabili   │ Lines of Code   │ Unique     │
│               │ Complexity   │ ty Index        │                 │ Operands   │
╞═══════════════╪══════════════╪═════════════════╪═════════════════╪════════════╡
│ tests/test_pr │ - -> 5       │ - -> 34.41295   │ - -> 101        │ - -> 5     │
│ edefined_conf │              │ 706943865       │                 │            │
│ igs.py        │              │                 │                 │            │
├───────────────┼──────────────┼─────────────────┼─────────────────┼────────────┤
│ tests/test_sy │ 4 -> 21      │ 64.6399 ->      │ 54 -> 193       │ 2 -> 2     │
│ stem.py       │              │ 38.5581         │                 │            │
├───────────────┼──────────────┼─────────────────┼─────────────────┼────────────┤
│ tests/test_ru │ 18 -> 25     │ 61.6137 ->      │ 102 -> 155      │ 1 -> 1     │
│ le_logic.py   │              │ 55.1505         │                 │            │
├───────────────┼──────────────┼─────────────────┼─────────────────┼────────────┤
│ tests/tui/tes │ 5 -> 8       │ 47.6192 ->      │ 87 -> 163       │ 1 -> 2     │
│ t_tui_types.p │              │ 41.2367         │                 │            │
│ y             │              │                 │                 │            │
├───────────────┼──────────────┼─────────────────┼─────────────────┼────────────┤
│ tests/tui/tes │ 34 -> 36     │ 43.4276 ->      │ 381 -> 440      │ 7 -> 7     │
│ t_tui.py      │              │ 38.0201         │                 │            │
╘═══════════════╧══════════════╧═════════════════╧═════════════════╧════════════╛

@Kilo59
Kilo59 merged commit e8f0af3 into main Aug 29, 2026
16 checks passed
@Kilo59
Kilo59 deleted the chore/audit-kitchen-sink-bump-ruff-0.16.5 branch August 29, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working config-recipe Domain-specific configuration examples and recipes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant