Make setting and retrieving pydocstyle settings less tedious - #12582
Merged
Conversation
Contributor
|
MichaReiser
approved these changes
Jul 30, 2024
An error occurred while trying to automatically change base from
alex/is-property
to
main
July 30, 2024 16:42
AlexWaygood
force-pushed
the
alex/is-property-2
branch
from
July 30, 2024 16:49
fc034c6 to
b9db609
Compare
AlexWaygood
force-pushed
the
alex/is-property-2
branch
from
July 30, 2024 17:11
b9db609 to
a047e64
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
pydocstylerules 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
Settingsstruct 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 ofQualifiedNames, which is tedious and verbose. This PR therefore makes theignore_decoratorsandproperty_decoratorsfields onruff_linter::rules::pydocstyle::settings::Settingsprivate. 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 ofQualifiedNames for theextra_propertyfield, rather than a slice ofQualifiedNames.Test Plan
No new tests added since this is a pure refactor that shouldn't change semantics at all.