Skip to content

Run pydocstyle in pre-commit #6382

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
Dec 12, 2022

Conversation

michaelosthege
Copy link
Member

@michaelosthege michaelosthege commented Dec 10, 2022

This runs pydocstyle in the pre-commit and fixes a bunch of things it complained about.

However, I had to silence many errors that were just too common:

id occurrences description
D100 62 Missing docstring in public module
D101 62 Missing docstring in public class
D102 568 Missing docstring in public method
D103 98 Missing docstring in public function
D104 10 Missing docstring in public package
D105 47 Missing docstring in magic method
D107 84 Missing docstring in init
D200 23 One-line docstring should fit on one line with quotes
D202 59 No blank lines allowed after function docstring
D203 254 1 blank line required before class docstring
D204 47 1 blank line required after class docstring
D205 155 1 blank line required between summary line and description
D209 16 Multi-line docstring closing quotes should be on a separate line
D212 231 Multi-line docstring summary should start at the first line
D213 330 Multi-line docstring summary should start at the second line
D301 30 Use r""" if any backslashes in a docstring
D400 349 First line should end with a period
D401 98 First line should be in imperative mood
D403 14 First word of the first line should be properly capitalized
D413 341 Missing blank line after last section
D415 334 First line should end with a period, question mark, or exclamation point
D417 089 Missing argument descriptions in the docstring

Closes #6378

Checklist

Major / Breaking Changes

  • None

Bugfixes / New features

  • None

Docs / Maintenance

  • Now running pydocstyle in the pre-commit
  • Fixed several docstring formatting issues.

@codecov
Copy link

codecov bot commented Dec 10, 2022

Codecov Report

Merging #6382 (944b85d) into main (adf6fff) will decrease coverage by 58.19%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #6382       +/-   ##
===========================================
- Coverage   94.79%   36.60%   -58.20%     
===========================================
  Files         148      148               
  Lines       27488    27488               
===========================================
- Hits        26058    10061    -15997     
- Misses       1430    17427    +15997     
Impacted Files Coverage Δ
pymc/blocking.py 95.55% <ø> (ø)
pymc/distributions/continuous.py 58.16% <ø> (-39.52%) ⬇️
pymc/distributions/discrete.py 55.52% <ø> (-43.71%) ⬇️
pymc/distributions/dist_math.py 42.85% <ø> (-44.58%) ⬇️
pymc/distributions/distribution.py 68.57% <ø> (-28.89%) ⬇️
pymc/distributions/multivariate.py 46.19% <ø> (-46.09%) ⬇️
pymc/distributions/transforms.py 51.26% <ø> (-48.11%) ⬇️
pymc/distributions/truncated.py 34.50% <ø> (-64.79%) ⬇️
pymc/gp/util.py 36.78% <ø> (-59.78%) ⬇️
pymc/logprob/abstract.py 81.70% <ø> (-15.86%) ⬇️
... and 133 more

@michaelosthege michaelosthege marked this pull request as ready for review December 11, 2022 00:48
@ricardoV94
Copy link
Member

Except for the D100s... it seems like we should have the others enabled and they shouldn't be too hard to fix no?

@michaelosthege
Copy link
Member Author

Except for the D100s... it seems like we should have the others enabled and they shouldn't be too hard to fix no?

Some of them are in conflict with black and have no effect on the output (D202,D203,D204). Those we can keep ignoring.

We should enable the others, but that will be one beginner friendly PR per number.
I'm not going to fix several hundred lines by hand on this branch.

@michaelosthege michaelosthege added this to the v5.0.0 milestone Dec 11, 2022
OriolAbril
OriolAbril previously approved these changes Dec 12, 2022
hooks:
- id: pydocstyle
args:
- --ignore=D100,D101,D102,D103,D104,D105,D107,D200,D202,D203,D204,D205,D209,D212,D213,D301,D400,D401,D403,D413,D415,D417
Copy link
Member

Choose a reason for hiding this comment

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

The convention arg is missing, we should be using numpy as convention (which should remove the contradictory warnings happening all at the same time)

Copy link
Member

Choose a reason for hiding this comment

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

e.g. D212 and D213 make no sense together.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tried it, but with --convention one can't pass --ignore and then we'd have hundreds of errors and would need to fix them all in one go (unrealistic..)

Copy link
Member

Choose a reason for hiding this comment

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

let's keep ignore then

@OriolAbril OriolAbril dismissed their stale review December 12, 2022 17:17

jumped the gun too fast

@OriolAbril
Copy link
Member

I have also just realised we have https://github.com/pymc-devs/pymc/blob/main/setup.cfg#L7 which seems to be ignored for some reason? maybe we ought to install pydocstyle[toml]?

michaelosthege and others added 2 commits December 12, 2022 18:29
Includes docstring formatting to reduce the number of error codes
that had to be silenced for pydocstyle to be happy.

Closes pymc-devs#6378
@michaelosthege michaelosthege merged commit f96594b into pymc-devs:main Dec 12, 2022
@michaelosthege michaelosthege deleted the pydocstyle-pre-commit branch December 12, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pydocstyle hook to pre-commit
3 participants