-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Exempt overriding methods from docstring_linter (fix #151692) #151906
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/151906
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit d315713 with merge base f84062f ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@amjames, take a quick look, bearing in mind this surprise... https://github.com/rec/test/blob/master/python/overrides.py |
return # A statement means no more decorators | ||
end = begin | ||
|
||
return list(decorators())[::-1] |
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.
return list(decorators())[::-1] | |
out = list(decorators()) | |
out.reverse() | |
return out |
Slight nit as it's mildly more efficient.
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.
Done!
I passed my 21st Python birthday a few months ago, I have re-read the fundamental pages a dozen times and yet I somehow did not know or remember that list.reverse
existed (list.sort
is to sorted
as list.reverse
is to reversed
)!
In return, I offer you the near-forgotten str.partition
(and rpartition
of course).
str.partition
is used just 11 times in torch/
, 21 times for rpartition
, as opposed to 546 times for str.split
and 26 uses of rsplit
, but if you look at the uses of str.split
, about half the time str.partition
might be a more appropriate choice (i.e. s.split(".")[0]
which might generate a lot of strings and keep just the first) or s.split(".")[1]
which has two possible issues - missing dots or the occasional second dot...
More, you can often use it to chain and prevent if
statements, because it always returns a triple. For example, to remove an optional prefix and suffix:
a = s.partition("_suffix")[0].rpartition("prefix_")[2]
(Once I discovered this, I wondered why removepre/suffix
were added?)
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
ghstack-source-id: 6959a2e Pull Request resolved: pytorch#151906
Stack from ghstack (oldest at bottom):