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

Fix docstrings in series.py #10712

Closed
wants to merge 4 commits into from

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Apr 22, 2022

This PR contributes to #10711 by fixing the style for series.py. It also ensures that pre-commit and running pydocstyle manually both produce the expected output so that future linting improvements (contributions to #10711) can be done as a good first issue by new contributors.

@vyasr vyasr added 3 - Ready for Review Ready for review by team doc Documentation Python Affects Python cuDF API. non-breaking Non-breaking change labels Apr 22, 2022
@vyasr vyasr added this to the CuDF Python Refactoring milestone Apr 22, 2022
@vyasr vyasr self-assigned this Apr 22, 2022
@vyasr vyasr requested a review from a team as a code owner April 22, 2022 00:19
@vyasr vyasr requested review from bdice and charlesbluca April 22, 2022 00:19
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

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

Comments attached - please ignore anything that I suggested if it blatantly conflicts with pydocstyle rules that I did not consider. I caught myself at least once (forgetting that pydocstyle requires starting with a verb, for instance). On the whole, this is a nice change and will help us improve documentation throughout the library!

python/.flake8 Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
@@ -3381,8 +3473,7 @@ def __init__(self, series):
@property # type: ignore
@_cudf_nvtx_annotate
def year(self):
"""
The year of the datetime.
"""Get the year of the datetime.
Copy link
Contributor

Choose a reason for hiding this comment

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

pandas doesn't use the "Get" term here or on other dt properties.

Suggested change
"""Get the year of the datetime.
"""The year of the datetime.

https://pandas.pydata.org/docs/reference/api/pandas.Series.dt.year.html

Copy link
Contributor

Choose a reason for hiding this comment

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

I realize now that this is due to pydocstyle requiring a verb at the beginning. I wish it didn't require that for properties... oh well. Ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is an error code where I chose to prefer changing the docstring over adding noqas. If you change your mind and decide that you prefer the noqas let me know, I'm happy to change it back to that too.

"""
Returns a DataFrame with the year, week, and day
calculated according to the ISO 8601 standard.
"""Return a DataFrame with the year, week, and day calculated according to the ISO 8601 standard.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd wrap this (so it doesn't break E501) and instead choose to break whichever rule requires the brief to be one line, if that's equally viable.

Copy link
Contributor Author

@vyasr vyasr Apr 25, 2022

Choose a reason for hiding this comment

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

My preference is to consistently break E501 rather than selectively break any other rule. Using fewer distinct noqas makes it easier for developers, and it also reduces the degree of subjectivity (docstring A is really too long so let's do multi-line, whereas docstring B is just a tiny bit too long so let's allow E501 breakage). Breaking the one-line brief rule is also much more likely to lead to accidentally invalid docstrings if someone inserts an extra newline unintentionally.

python/cudf/cudf/core/series.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

Merging #10712 (a71c64c) into branch-22.06 (01d08af) will increase coverage by 0.03%.
The diff coverage is 98.50%.

❗ Current head a71c64c differs from pull request most recent head f991f97. Consider uploading reports for the commit f991f97 to get more accurate results

@@               Coverage Diff                @@
##           branch-22.06   #10712      +/-   ##
================================================
+ Coverage         86.35%   86.39%   +0.03%     
================================================
  Files               142      142              
  Lines             22335    22297      -38     
================================================
- Hits              19287    19263      -24     
+ Misses             3048     3034      -14     
Impacted Files Coverage Δ
python/cudf/cudf/core/frame.py 93.41% <ø> (ø)
python/cudf/cudf/utils/utils.py 90.35% <ø> (+0.06%) ⬆️
python/cudf/cudf/core/column/numerical.py 96.17% <50.00%> (+0.29%) ⬆️
python/cudf/cudf/core/column/categorical.py 89.97% <100.00%> (+0.20%) ⬆️
python/cudf/cudf/core/column/column.py 89.43% <100.00%> (-0.02%) ⬇️
python/cudf/cudf/core/column/lists.py 92.91% <100.00%> (+1.39%) ⬆️
python/cudf/cudf/core/column/string.py 89.21% <100.00%> (+0.10%) ⬆️
python/cudf/cudf/core/dataframe.py 93.75% <100.00%> (+<0.01%) ⬆️
python/cudf/cudf/core/groupby/groupby.py 91.68% <100.00%> (+0.27%) ⬆️
python/cudf/cudf/core/multiindex.py 92.28% <100.00%> (+0.13%) ⬆️
... and 8 more

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 5053a1a...f991f97. Read the comment docs.

@vyasr
Copy link
Contributor Author

vyasr commented Apr 27, 2022

In light of our subsequent discussions on #10711, I'm going to close this PR since it makes a bunch of unnecessary and possibly undesirable changes. I'll reopen a new one with a minimal set of changes to demonstrate how we'd like these PRs to look going forward.

@vyasr vyasr closed this Apr 27, 2022
@vyasr vyasr deleted the feature/pydocstyle_updates branch January 23, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team doc Documentation non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants