Skip to content

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

Closed
wants to merge 9 commits into from

Conversation

rec
Copy link
Collaborator

@rec rec commented Apr 22, 2025

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Apr 22, 2025

🔗 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 SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit d315713 with merge base f84062f (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
[ghstack-poisoned]
rec added a commit that referenced this pull request Apr 22, 2025
[ghstack-poisoned]
@rec rec changed the title Exempt overridden methods from docstring_linter (fix #151692) Exempt overriding methods from docstring_linter (fix #151692) Apr 22, 2025
@rec rec requested a review from amjames April 22, 2025 16:19
@rec
Copy link
Collaborator Author

rec commented Apr 22, 2025

@amjames, take a quick look, bearing in mind this surprise... https://github.com/rec/test/blob/master/python/overrides.py

[ghstack-poisoned]
rec added a commit that referenced this pull request Apr 22, 2025
@rec rec marked this pull request as ready for review April 23, 2025 09:22
[ghstack-poisoned]
rec added a commit that referenced this pull request Apr 24, 2025
[ghstack-poisoned]
return # A statement means no more decorators
end = begin

return list(decorators())[::-1]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return list(decorators())[::-1]
out = list(decorators())
out.reverse()
return out

Slight nit as it's mildly more efficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


@Skylion007

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?)

[ghstack-poisoned]
@rec
Copy link
Collaborator Author

rec commented Apr 29, 2025

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 29, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

[ghstack-poisoned]
@rec
Copy link
Collaborator Author

rec commented May 5, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

rec added a commit to rec/pytorch that referenced this pull request May 12, 2025
@github-actions github-actions bot deleted the gh/rec/145/head branch June 14, 2025 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants