PyCQA / pydocstyle

docstring style checker
http://pydocstyle.org
MIT License
1.11k stars 188 forks source link

fix: do not pass file names with pre-commit #610

Closed yajo closed 1 year ago

yajo commented 1 year ago

This is the only way pydocstyle will obey its own match rules.

Thanks for submitting a PR!

Please make sure to check for the following items:

Please don't get discouraged as it may take a while to get a review.

bszonye commented 1 year ago

This change is causing pre-commit to emit a warning:

$ pre-commit run --all-files
[WARNING] Unexpected key(s) present on https://github.com/pycqa/pydocstyle => pydocstyle: pass_file_names

It looks like the correct spelling of the option is pass_filenames: https://pre-commit.com/#hooks-pass_filenames

Is this change actually working as expected?

bszonye commented 1 year ago

Also, this appears to change the documented behavior here: https://www.pydocstyle.org/en/stable/usage.html#usage-with-the-pre-commit-git-hooks-framework

Checked-in python files will be passed as positional arguments so no need to use --match=*.py. You can also use command line arguments instead of configuration files to achieve the same effect with less files.

If that's changing then the documentation needs an update and possibly instructions for how to get the old behavior:

- repo: https://github.com/pycqa/pydocstyle
  rev: 6.2.3
  hooks:
  - id: pydocstyle
    pass_filenames: true
bszonye commented 1 year ago

Should I move my comments here to a new issue? I noticed that a revert commit has been opened and closed a couple times now.

samj1912 commented 1 year ago

This commit has been reverted.

bszonye commented 1 year ago

Thanks! By the way, I discovered accidentally that the underlying issue that motivated this PR might have already been addressed. Please see my comment here: https://github.com/PyCQA/pydocstyle/issues/111#issuecomment-1374921227

bszonye commented 1 year ago

Aha, I was still seeing the error in pre-commit because this:

- repo: https://github.com/pycqa/pydocstyle
  rev: 6.2.3
  hooks:
  - id: pydocstyle

gets the broken config from the 6.2.3 release. Reverting my config to 6.2.2 works around the problem.