Skip to content
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

Make setting and retrieving pydocstyle settings less tedious #12582

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

AlexWaygood
Copy link
Member

Summary

This PR is stacked on top of #12581.

The pydocstyle rules have settings that allow you to specify a list of decorators that should be considered property-like, and a list of decorators that should be ignored. The list of property-like decorators isn't just read by the pydocstyle rules; it's also used by many other rules so that they can pass in "extra" property-like decorators to ruff_python_semantic::analyze::visibility::is_property().

Currently the pydocstyle Settings struct exposes these two settings as BTreeSet<String>, however, which is somewhat useless. To do any analysis with these values, rules first have to convert these lists into lists of QualifiedNames, which is tedious and verbose. This PR therefore makes the ignore_decorators and property_decorators fields on ruff_linter::rules::pydocstyle::settings::Settings private. Instead, it exposes public methods for setting the fields, and public methods for lazily iterating over the property-decorators or ignored-decoratos where the iterators map each decorator to a QualifiedName. The PR also adjusts ruff_python_semantic::analyze::visibility::is_property() so that it is able to receive a lazy iterator of QualifiedNames for the extra_property field, rather than a slice of QualifiedNames.

Test Plan

No new tests added since this is a pure refactor that shouldn't change semantics at all.

@AlexWaygood AlexWaygood added the internal An internal refactor or improvement label Jul 30, 2024
Copy link
Contributor

github-actions bot commented Jul 30, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

crates/ruff_python_semantic/src/analyze/visibility.rs Outdated Show resolved Hide resolved
crates/ruff_python_semantic/src/definition.rs Outdated Show resolved Hide resolved
crates/ruff_workspace/src/options.rs Show resolved Hide resolved
Base automatically changed from alex/is-property to main July 30, 2024 16:42
An error occurred while trying to automatically change base from alex/is-property to main July 30, 2024 16:42
@AlexWaygood AlexWaygood merged commit 83b1c48 into main Jul 31, 2024
20 checks passed
@AlexWaygood AlexWaygood deleted the alex/is-property-2 branch July 31, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants