Skip to content
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

bpo-31567: Use decorator markup for staticmethod()/classmethod() #3959

Merged
merged 4 commits into from
Oct 12, 2017

Conversation

dmiyakawa
Copy link
Contributor

@dmiyakawa dmiyakawa commented Oct 12, 2017

staticmethod() and classmethod() are expected to be used with decorator, so documentation should mention it.

https://bugs.python.org/issue31567

@@ -196,7 +196,7 @@ are always available. They are listed here in alphabetical order.
base 16). :exc:`ValueError` will be raised if *i* is outside that range.


.. function:: classmethod(function)
.. decorator:: classmethod(function)
Copy link
Member

@merwok merwok Oct 12, 2017

Choose a reason for hiding this comment

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

I suspect that this should be decorator: classmethod; the version with arguments is probably used for functions that are decorator factories.

(For example, @functools.lru_cache(max_size=20) gets arguments and returns a decorator which is then applied to the decorated function; the markup must show clearly if people are expected to call @decorator or @decorator_factory().)

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@dmiyakawa
Copy link
Contributor Author

I have made the requested changes; please review again.

Removed "(function)" for both classmethod and staticmethod. Since the following explanations points to the name "function" in the arg, I modified the description too (I mimicked the line in @functools.singledispatch)

https://docs.python.org/3.6/library/functools.html#functools.singledispatch

Transforms a function into a single-dispatch generic function.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@merwok: please review the changes made to this pull request.

Use command form like in docstrings
@merwok
Copy link
Member

merwok commented Oct 12, 2017

Thanks! Sphinx docs for the reference: http://www.sphinx-doc.org/en/1.6.4/domains.html#directive-py:decorator

I found three misuses of the markup (including singledispatch!) which I will fix in this PR, given that the original ticket was not only about staticmethod and classmethod.

@merwok
Copy link
Member

merwok commented Oct 12, 2017

I wasn’t able to push my commit to your fork (I expected that to be possible given that I could add a commit within github), and I can’t find your fork in the widget to create cross-forks PRs.

https://help.github.com/articles/committing-changes-to-a-pull-request-branch-created-from-a-fork/

@dmiyakawa
Copy link
Contributor Author

Sorry I'm not sure what is going on...

I can see you actually added some changes in my PR, I I understand you can add more commits here
dmiyakawa@9b806c1

"Allow edits from maintainers" check in this page looks already on.
https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/

@merwok
Copy link
Member

merwok commented Oct 12, 2017

Yes that’s the one in created from github. I made another commit on my laptop and can’t push it to your fork or make a PR: merwok@59bc4a7

@dmiyakawa
Copy link
Contributor Author

Tried merging the change in merwok/cpython to dmiyakawa/cpython.

@miss-islington
Copy link
Contributor

Thanks @dmiyakawa for the PR, and @merwok for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-3965 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 12, 2017
@miss-islington
Copy link
Contributor

Sorry, @dmiyakawa and @merwok, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 0e61e67a57deb4abc677808201d7cf3c38138e02 2.7

@python python deleted a comment from miss-islington Oct 12, 2017
@python python deleted a comment from miss-islington Oct 12, 2017
@merwok
Copy link
Member

merwok commented Oct 12, 2017

I’ll leave 2.7 alone, nothing already uses the decorator markup (maybe it’s not even supported in the sphinx version used by 2.7).

@merwok
Copy link
Member

merwok commented Oct 12, 2017

FTR I think the push issue was due to using an https URL for your fork rather than ssh!
I just pushed commits to the backport PR owned by the miss-islington bot.

merwok pushed a commit that referenced this pull request Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants