-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[pydocstyle
] Handle arguments with the same names as sections (D417
)
#16011
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
90c8b64
add failing regression test
ntBre 4a87ab1
pass tests
ntBre 7c39487
clean up unused method
ntBre c9a0f86
more test cases, second failing
ntBre 05717d1
compare section names to known arguments
ntBre 2bcd655
update snaps
ntBre 79cff7f
allow too_many_arguments
ntBre 308c49b
use Docstring::definition
ntBre 7212177
linear search instead of hashset
ntBre c4fe958
add example for verbatim parameter name
ntBre 0bc81b9
move docs
ntBre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a test where one of the function arguments is named like a section header? I'm curious what happens if that argument is undocumented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you had in mind? I added these two cases, both of which cause D417. The first one is right,
Args
is not documented, but the second is still a false positive that I can keep working on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I had in mind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cases should work now! I initially deleted the inner conditional here
ruff/crates/ruff_linter/src/docstrings/sections.rs
Lines 525 to 529 in 1f7a29d
which worked well for D417 but broke other rules like D214 - overindented-section. So I went for the more involved approach of passing down a
Definition
and extracting known parameter names from it.One other thing I considered is just searching for a known parameter at line 514 instead of collecting a
HashSet
up front.