Make setting and retrieving pydocstyle settings less tedious #12582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toruff_python_semantic::analyze::visibility::is_property()
.Currently the pydocstyle
Settings
struct exposes these two settings asBTreeSet<String>
, however, which is somewhat useless. To do any analysis with these values, rules first have to convert these lists into lists ofQualifiedName
s, which is tedious and verbose. This PR therefore makes theignore_decorators
andproperty_decorators
fields onruff_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 aQualifiedName
. The PR also adjustsruff_python_semantic::analyze::visibility::is_property()
so that it is able to receive a lazy iterator ofQualifiedName
s for theextra_property
field, rather than a slice ofQualifiedName
s.Test Plan
No new tests added since this is a pure refactor that shouldn't change semantics at all.