Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 2 commits into from
May 6, 2018
Merged

Minor cleanup to Text class. #9832

merged 2 commits into from
May 6, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 22, 2017

  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.

edit: added various style fixes across the module...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@dstansby dstansby added this to the v2.2 milestone Nov 22, 2017
Copy link
Member

@efiring efiring left a 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."""
Copy link
Member

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.

Copy link
Contributor Author

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...

Copy link
Member

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?

Copy link
Member

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.

@jklymak jklymak modified the milestones: needs sorting, v3.0 Mar 29, 2018
@anntzer
Copy link
Contributor Author

anntzer commented Mar 29, 2018

rebased

@jklymak
Copy link
Member

jklymak commented Mar 29, 2018

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

@@ -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."""
Copy link
Member

Choose a reason for hiding this comment

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

the

Copy link
Contributor Author

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.
@timhoffm
Copy link
Member

timhoffm commented May 6, 2018

I'm taking the freedom of merging without waiting for a definitive single-line-triple-quote decision.

  • Currently we don't have an official policy on that topic and it seems to be controversial.
  • The used format conforms with PEP-8.
  • There are already numerous places in our codebase that use this format.

@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.

@timhoffm timhoffm merged commit fb17040 into matplotlib:master May 6, 2018
@anntzer anntzer deleted the text branch May 6, 2018 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants