This repository was archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 189
D401: Allow multiple imperative forms of the same stem. #382
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
af5bb1f
Allow multiple imperative forms of the same stem.
Nurdok ee4e264
Update phrasing of violation.
Nurdok d9c35a9
Select best imperative by longest prefix match
lordmauve 6e16b2d
Fixed test after merge.
Nurdok cf3179a
Added line to release notes.
Nurdok 7ecda39
Code review fixes.
Nurdok 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 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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Unit test for pydocstyle utils. | ||
|
||
Use tox or py.test to run the test suite. | ||
""" | ||
from pydocstyle import utils | ||
|
||
|
||
__all__ = () | ||
|
||
|
||
def test_common_prefix(): | ||
"""Test common prefix length of two strings.""" | ||
assert utils.common_prefix_length('abcd', 'abce') == 3 | ||
|
||
|
||
def test_no_common_prefix(): | ||
"""Test common prefix length of two strings that have no common prefix.""" | ||
assert utils.common_prefix_length('abcd', 'cdef') == 0 | ||
|
||
|
||
def test_differ_length(): | ||
"""Test common prefix length of two strings differing in length.""" | ||
assert utils.common_prefix_length('abcd', 'ab') == 2 | ||
|
||
|
||
def test_empty_string(): | ||
"""Test common prefix length of two strings, one of them empty.""" | ||
assert utils.common_prefix_length('abcd', '') == 0 |
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.
"perhaps y, not x" reads clumsily to me. Adding "perhaps y" suggests a lot less confidence in the recommendation, while "not x" seems very confident.
Maybe "eg. y instead of x"?
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.
Seeing as the bug was caused by two different imperative forms of the same stem, I was indeed going for a less confident recommendation.
Some options here:
I chose (1) because it's more clear that 'Runs' is definitely bad while 'Run' is not necessarily the right choice.
@shacharoo LMKWYT
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.
I'm merging so that other PRs are unblocked, I think the current phrasing is fine for now, but we can revisit it before the next release.
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.
Thanks. (I like 3 and 4 for what it's worth).