Skip to content

Ignoring Rules like DOC101 and DOC103 #228

Open

Description

@bbaabemhp

Hi guys,

first of all thanks for the awesome library!

I wanted to ignore some rules by default (instead of always ignoring them in-line in code)

I tried out ignoring them in my pyproject.toml somehow, but without any luck:

[tool.pydoclint]
style = 'numpy'
ignore = ["DOC101","DOC103"]

Would be awesome to find a solution. Thanks!

Activity

  1. jsh9 commented on Apr 3, 2025

    @jsh9
    Owner

    Hi @bbaabemhp , you can use the flake8 mode to ignore certain violations in a config file. This is essentially using pydoclint as a flake8 plug in.

    Read more here: https://github.com/jsh9/pydoclint?tab=readme-ov-file#22-as-a-flake8-plugin

  2. bbaabemhp commented on Apr 3, 2025

    @bbaabemhp
    Author

    Is there also a way for ruff? Somehow it is not working :/

  3. jsh9 commented on Apr 16, 2025

    @jsh9
    Owner

    Hi @bbaabemhp , could you rephrase your most recent question? I don't quite understand it. Thanks!

  4. jameslamb commented on Sep 30, 2026

    @jameslamb

    👋🏻 first time commenter... thanks for this excellent project! I just learned about it today and think it'll help a lot in projects I work on.

    After a bit of time experimenting, I want to +1 this required. I'd also like to not need to involve flake8 but still skip specific rules globally.

    Here's a minimal example of something I'm facing:

    TMPDIR=$(mktemp -d)
    pushd ${TMPDIR}
    
    cat > ./mod.py <<EOF
    from typing import Type
    
    class SomeClass:
       pass
    
    class OtherClass:
       pass
    
    _AllowedInputTypes = SomeClass | OtherClass
    
    def do_stuff(x: _AllowedInputTypes) -> None:
        """
        Convert to integer.
    
        Parameters
        ----------
    
        x : ``SomeClass`` or ``OtherClass`` instance
          an input
        """
        pass
    EOF
    
    cat > ./.pre-commit-config.yaml <<EOF
    repos:
      - repo: https://github.com/pre-commit/mirrors-mypy
        rev: v2.1.0
        hooks:
          - id: mypy
            args: ["--config-file", "pyproject.toml"]
      - repo: https://github.com/jsh9/pydoclint
        rev: 0.10.1
        hooks:
          - id: pydoclint
            args: [--config=pyproject.toml]
    EOF
    
    cat >./pyproject.toml <<EOF
    [tool.pydoclint]
    check_arg_order = true
    check_return_types = false
    style = "numpy"
    EOF
    
    git init .
    git add .
    git commit -m "initial commit"

    That's valid Python and mypy is happy with it, but this project isn't, I think because the spelling of the type hint in the docstring doesn't match the spelling in the code.

    $ pre-commit run --all-files
    mypy.....................................................................Passed
    pydoclint................................................................Failed
    - hook id: pydoclint
    - exit code: 1
    
    Skipping files that match this pattern: \.git|\.tox
    mod.py
    mod.py
        11: DOC105: Function `do_stuff`: Argument names match, but type hints in these args do not match: x

    I'd like to be able to use RST markup (like cross-references) and more readable formats of spelling the type hint and not need to exactly match the spelling in the code.

    The spec in the numpy docs implies that the type hint could be free-form human-readable text and doesn't need to precisely match the Python object names used to refer to types: https://numpydoc.readthedocs.io/en/latest/format.html#parameters

    I'd love to be able to do something like what @bbaabemhp suggested in pyproject.toml.

    [tool.pydoclint]
    ignore = ["D105"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions