Skip to content

Make setting and retrieving pydocstyle settings less tedious - #12582

Merged
AlexWaygood merged 1 commit into
mainfrom
alex/is-property-2
Jul 31, 2024
Merged

Make setting and retrieving pydocstyle settings less tedious#12582
AlexWaygood merged 1 commit into
mainfrom
alex/is-property-2

Conversation

@AlexWaygood

Copy link
Copy Markdown
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
@github-actions

github-actions Bot commented Jul 30, 2024

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Comment thread crates/ruff_python_semantic/src/analyze/visibility.rs Outdated
Comment thread crates/ruff_python_semantic/src/definition.rs Outdated
Comment thread crates/ruff_workspace/src/options.rs
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
@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