Skip to content

Create a unified RuleConfig abstraction #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

nathanjmcdougall
Copy link
Owner

No description provided.

@nathanjmcdougall nathanjmcdougall linked an issue Apr 24, 2025 that may be closed by this pull request
Copy link

codspeed-hq bot commented Apr 24, 2025

CodSpeed Performance Report

Merging #569 will not alter performance

Comparing 563-create-a-unified-abstraction-for-ruleconfig (3e128cf) with main (c5e8b27)

Summary

✅ 1 untouched benchmarks

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.27%. Comparing base (c5e8b27) to head (3e128cf).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #569   +/-   ##
=======================================
  Coverage   97.27%   97.27%           
=======================================
  Files          87       87           
  Lines        4143     4152    +9     
=======================================
+ Hits         4030     4039    +9     
  Misses        113      113           

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

@nathanjmcdougall nathanjmcdougall merged commit 7d254de into main Apr 24, 2025
17 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 563-create-a-unified-abstraction-for-ruleconfig branch April 24, 2025 20:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a unified RuleConfig abstraction to replace the previous get_associated_ruff_rules method across tools and tests. Key changes include updating tests to use RuleConfig, refactoring methods in src/usethis/_tool.py and src/usethis/_core/tool.py to return and consume RuleConfig instances, and extracting a helper (_get_basic_rule_config) in use_ruff.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/usethis/test_usethis_tool.py Updated tests to use get_rule_config and compare against RuleConfig
src/usethis/_tool.py Removed get_associated_ruff_rules and introduced get_rule_config returning RuleConfig
src/usethis/_core/tool.py Adjusted use_pytest and use_ruff to consume RuleConfig values and added _get_basic_rule_config helper
Comments suppressed due to low confidence (2)

src/usethis/_core/tool.py:252

  • [nitpick] Consider adding a brief inline comment to clarify why get_all_selected() (including both managed and unmanaged selected rules) is used when selecting rules, while only rule_config.selected is used when deselecting rules. This will help future maintainers understand the intended behavior.
RuffTool().select_rules(rule_config.get_all_selected())

src/usethis/_core/tool.py:361

  • [nitpick] If _get_basic_rule_config is expected to be used in multiple contexts, consider refactoring it into a shared utility module for better modularity.
def _get_basic_rule_config() -> RuleConfig:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a unified abstraction for RuleConfig
1 participant