-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Conversation
Doc/library/functions.rst
Outdated
@@ -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) |
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 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()
.)
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 |
34cd57a
to
8c8e4b4
Compare
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
|
Thanks for making the requested changes! @merwok: please review the changes made to this pull request. |
Use command form like in docstrings
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. |
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/ |
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 "Allow edits from maintainers" check in this page looks already on. |
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 |
fix decorator markup
Tried merging the change in merwok/cpython to dmiyakawa/cpython. |
Thanks @dmiyakawa for the PR, and @merwok for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
GH-3965 is a backport of this pull request to the 3.6 branch. |
(cherry picked from commit 0e61e67)
Sorry, @dmiyakawa and @merwok, I could not cleanly backport this to |
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). |
FTR I think the push issue was due to using an https URL for your fork rather than ssh! |
staticmethod() and classmethod() are expected to be used with decorator, so documentation should mention it.
https://bugs.python.org/issue31567