Skip to content

DOC: Make _field_accessor manage the docstring format #24072

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

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Dec 3, 2018

@pep8speaks
Copy link

Hello @charlesdong1991! Thanks for submitting the PR.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

I think we can make this simpler, see comment.

if not docstring.startswith("\n"):
docstring = "".join(("\n", docstring))
if not docstring.endswith("\n"):
docstring = "".join((docstring, "\n"))
f.__doc__ = docstring
Copy link
Member

Choose a reason for hiding this comment

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

I'd make it as simple as:

Suggested change
f.__doc__ = docstring
f.__doc__ = '\n{}\n'.format(docstring)

Without the code you added.

Then, in the calls to _field_accessor we need to remove the \n and spaces around the description. I think that should work in all cases.

Copy link
Member Author

@charlesdong1991 charlesdong1991 Dec 3, 2018

Choose a reason for hiding this comment

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

oh, okay, @datapythonista thanks for the review, i did think about this solution, then i thought if in the call to _field_accessor, we already used \n, then directly adding \n will be redundant... so i made a if judgement first..
but agree that if remove the \n added before, then this should not be the problem and look much simpler...

Copy link
Member

Choose a reason for hiding this comment

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

we may have to do what you did if at some point we have something like:

_doc = """
Some summary.
"""
foo = _field_accessor(..., _doc)

But we'll complicate things at that point, if they ever happen. And to join two strings, I think it's better to use '\n' + foo of '\n{}'.format(foo) than using a join.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, thanks for the tip!! @datapythonista

@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #24072 into master will increase coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24072      +/-   ##
==========================================
+ Coverage   42.38%   42.39%   +<.01%     
==========================================
  Files         161      161              
  Lines       51699    51709      +10     
==========================================
+ Hits        21913    21920       +7     
- Misses      29786    29789       +3
Flag Coverage Δ
#single 42.39% <87.5%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimes.py 64.07% <100%> (+0.28%) ⬆️
pandas/core/arrays/timedeltas.py 39.06% <75%> (+0.09%) ⬆️
pandas/core/arrays/integer.py 38.06% <0%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7bb972...62d1599. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #24072 into master will increase coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24072      +/-   ##
==========================================
+ Coverage   42.38%   42.39%   +<.01%     
==========================================
  Files         161      161              
  Lines       51699    51709      +10     
==========================================
+ Hits        21913    21920       +7     
- Misses      29786    29789       +3
Flag Coverage Δ
#single 42.39% <87.5%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/datetimes.py 64.07% <100%> (+0.28%) ⬆️
pandas/core/arrays/timedeltas.py 39.06% <75%> (+0.09%) ⬆️
pandas/core/arrays/integer.py 38.06% <0%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7bb972...62d1599. Read the comment docs.

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.

DOC: Make _field_accessor manage the docstring format
3 participants