Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

👌 Add pre-commit-hook to run pydoclint via flake8 #200

Merged
merged 2 commits into from
Jan 11, 2025

Conversation

s-weigand
Copy link
Contributor

Since I want the inline ignore feature when running pydoclint via flake8 I'm using a hook like so.

  - repo: https://github.com/PyCQA/flake8
    rev: 7.1.1
    hooks:
      - id: flake8
        alias: flake8-docs
        args:
          - "--select=DOC"
          - "--extend-ignore=DOC502,DOC601,DOC603"
          - "--color=always"
          - "--require-return-section-when-returning-nothing=False"
          - "--allow-init-docstring=True"
          - "--skip-checking-short-docstrings=False"
        name: "lint docstrings"
        exclude: "^(docs/|tests?/)"
        additional_dependencies: [pydoclint==0.5.6]

This has the obvious drawback that I manually need to look up the latest version of pydoclint and update it (If I don't forget the additional dependency, see how outdated it is 😥).

Having a flake8 based hook in the pydoclint repo would allow me to easily keep up with the latest and greatest version.

  - repo: https://github.com/jsh9/pydoclint
    rev: <autoupdatable version>
    hooks:
      - id: pydoclint-flake8
        alias: flake8-docs
        args:
          - "--select=DOC"
          - "--extend-ignore=DOC502,DOC601,DOC603"
          - "--color=always"
          - "--require-return-section-when-returning-nothing=False"
          - "--allow-init-docstring=True"
          - "--skip-checking-short-docstrings=False"
        name: "lint docstrings"
        exclude: "^(docs/|tests?/)"

@s-weigand
Copy link
Contributor Author

While writing the PR body it came to my mind that I could also just overwrite the entry of the existing hook to get the same effect.

  - repo: https://github.com/jsh9/pydoclint
    rev: ""
    hooks:
      - id: pydoclint
        alias: lint-docs
        entry: flake8
        args:
          - "--select=DOC"
          - "--extend-ignore=DOC502,DOC601,DOC603"
          - "--color=always"
          - "--require-return-section-when-returning-nothing=False"
          - "--allow-init-docstring=True"
          - "--skip-checking-short-docstrings=False"
        name: "lint docstrings"
        exclude: "^(docs/|tests?/)"
        additional_dependencies: [flake8]

However I think that running pydoclint via flake8 is such a common need that it would justify its own hook.

@jsh9
Copy link
Owner

jsh9 commented Jan 11, 2025

This is a very good idea. Thanks!

Let me add version bump and other stuff to this PR.

@jsh9 jsh9 merged commit 7282eb6 into jsh9:main Jan 11, 2025
16 checks passed
@s-weigand s-weigand deleted the add-flake8-hook branch January 13, 2025 08:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants