Skip to content

CI: add pydocstyle to code_checks #32033

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,13 @@ fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

echo "pydocstyle --version"
pydocstyle --version

MSG='Validate docstrings using pydocstyle (see setup.cfg for selected error codes)' ; echo $MSG
pydocstyle pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Validate docstrings (GL03, GL04, GL05, GL06, GL07, GL09, GL10, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA02, SA03, SA05)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL03,GL04,GL05,GL06,GL07,GL09,GL10,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA02,SA03,SA05
RET=$(($RET + $?)) ; echo $MSG "DONE"
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
- isort # check that imports are in the right order
- mypy=0.730
- pycodestyle # used by flake8
- pydocstyle

# documentation
- gitpython # obtain contributors from git for whatsnew
Expand Down
7 changes: 3 additions & 4 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ def __iter__(self):
------
tstamp : Timestamp
"""

# convert in chunks of 10k for efficiency
data = self.asi8
length = len(self)
Expand Down Expand Up @@ -820,7 +819,9 @@ def tz_convert(self, tz):
dtype = tz_to_dtype(tz)
return self._simple_new(self.asi8, dtype=dtype, freq=self.freq)

def tz_localize(self, tz, ambiguous="raise", nonexistent="raise"):
# TODO: remove # noqa once https://github.com/PyCQA/pydocstyle/pull/441
# is merged
def tz_localize(self, tz, ambiguous="raise", nonexistent="raise"): # noqa
Copy link
Member

Choose a reason for hiding this comment

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

Why is the noqa needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

another continuation line issue.

Copy link
Member

Choose a reason for hiding this comment

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

Can we rather figure out what is wrong, or disable the indentation check?

Copy link
Member Author

Choose a reason for hiding this comment

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

probably need a fix upstream

Copy link
Member Author

Choose a reason for hiding this comment

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

looks like an issue has already been raised for this PyCQA/pydocstyle#437

"""
Localize tz-naive Datetime Array/Index to tz-aware
Datetime Array/Index.
Expand Down Expand Up @@ -1640,7 +1641,6 @@ def to_julian_date(self):
0 Julian date is noon January 1, 4713 BC.
https://en.wikipedia.org/wiki/Julian_day
"""

# http://mysite.verizon.net/aesir_research/date/jdalg2.htm
year = np.asarray(self.year)
month = np.asarray(self.month)
Expand Down Expand Up @@ -1705,7 +1705,6 @@ def sequence_to_dt64ns(
------
TypeError : PeriodDType data is passed
"""

inferred_freq = None

dtype = _validate_dt64_dtype(dtype)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def to_datetime(
infer_datetime_format=False,
origin="unix",
cache=True,
):
): # noqa: D207
Copy link
Member

Choose a reason for hiding this comment

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

same question here?

Copy link
Member Author

Choose a reason for hiding this comment

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

there looks to be a problem with the use of continuation. The next line is flagged as underindented (D207).

Copy link
Member

Choose a reason for hiding this comment

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

It's black that requires this, so I would maybe not include the D207 check then, if it gives conflicts with black.

Copy link
Member Author

Choose a reason for hiding this comment

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

disabling D207 on one or two functions is better than disabling on all, surely?

Copy link
Member Author

Choose a reason for hiding this comment

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

"""
Convert argument to datetime.

Expand Down
1 change: 1 addition & 0 deletions pandas/io/excel/_openpyxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def _convert_to_protection(cls, protection_dict):

Returns
-------
openpyxl.styles.Protection
"""
from openpyxl.styles import Protection

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ flake8-rst>=0.6.0,<=0.7.0
isort
mypy==0.730
pycodestyle
pydocstyle
gitpython
gitdb2==2.0.6
sphinx
Expand Down
14 changes: 14 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ ignore = E402, # module level import not at top of file
exclude =
doc/source/development/contributing_docstring.rst

[pydocstyle]
select = D201, # No blank lines allowed before function docstring
D202, # No blank lines allowed after function docstring
D204, # 1 blank line required after class docstring
D207, # Docstring is under-indented
D208, # Docstring is over-indented
D209, # Multi-line docstring closing quotes should be on a separate line
D213, # Multi-line docstring summary should start at the second line
D300, # Use triple double quotes
D409, # Section underline should match the length of its name
D411, # Missing blank line before section
D412, # No blank lines allowed between a section header and its content
D414, # Section has no content

[tool:pytest]
# sync minversion with setup.cfg & install.rst
minversion = 4.0.2
Expand Down