-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor cleanup to Text class. #9832
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
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.
Apart from my request that you reconsider the docstring quote-mark patterns, this is fine.
@@ -38,7 +38,7 @@ | |||
|
|||
|
|||
def _process_text_args(override, fontdict=None, **kwargs): | |||
"Return an override dict. See :func:`~pyplot.text' docstring for info" | |||
"""Return an override dict. See `~pyplot.text' docstring for info.""" |
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.
Style nit-picks: Since the primary function of triple quotes is to generate multi-line text blocks, I would prefer to see them used in docstrings only in the form
"""
This is a docstring that might have more than one line.
"""
If you want a docstring to occupy only a single line, to save space, then I think you should use quotes as in the line above before your change. When I see triple quotes, I want to see the ending triple on a subsequent line; and starting a docstring with triple quotes followed by text on the same line looks ugly to me.
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.
This is actually explicitly specified in https://www.python.org/dev/peps/pep-0257/#one-line-docstrings. If we decide to explicitly not follow that recommendation it should probably go into the documentation guidelines...
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.
Agreed. I think that PEP is giving bad advice with a silly rationale, but it's not critical. @tacaswell, do you want to follow the PEP for new code and whenever existing docstrings are edited?
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.
Maybe it's just habit, but using always triple quotes feels more consistent. Docstrings look more alike. Even though the rationale in PEP-257 is of course nonsense, I would stick to the suggested conventions.
rebased |
@efiring should we agree to disagree on this (well not me -I am not too fussy about such things ) or do you still want this changed? |
lib/matplotlib/text.py
Outdated
@@ -266,11 +261,11 @@ def set_rotation_mode(self, m): | |||
self.stale = True | |||
|
|||
def get_rotation_mode(self): | |||
"get text rotation mode" | |||
"""Get text rotation mode.""" |
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.
the
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.
fixed
1. Remove some unneeded newlines in the class docstring. 2. Add a space after commas in the repr. 3. Make the constructor docstring's first sentence fit in one line.
I'm taking the freedom of merging without waiting for a definitive single-line-triple-quote decision.
@efiring If you feel strongly on the formatting and want a definitive decision please open a separate issue to discuss it. We would have to add any deviations from PEP-8 to the coding style guide and adapt multiple places in the code. That's beyond the scope of the PR. |
edit: added various style fixes across the module...
PR Summary
PR Checklist