jsh9 / pydoclint

A Python docstring linter that checks arguments, returns, yields, and raises sections
https://pypi.org/project/pydoclint/
MIT License
149 stars 15 forks source link

[feature] Hide settings, to be null-ls friendly #166

Open aemonge opened 2 months ago

aemonge commented 2 months ago

To be able to integrate this on null-ls ( now none-ls ) as a editor diagnostics, we need to remove the header extra info.

I've "by-passed" it by wrapping it in:

pydoclint \
    --show-filenames-in-every-violation-message=true \
    -q "$@" \
    | awk '/^[^:]+:[0-9]+: / {print $0}' \
    | sort -u

But would be great to only show header (config info) if asked --info

aemonge commented 2 months ago

https://github.com/nvimtools/none-ls.nvim/pull/181

jsh9 commented 2 months ago

Hi @aemonge , could you explain what you meant by "header extra info"? Maybe an example would help. Thanks!

aemonge commented 2 months ago

Sure :)

Given a file like:

❯ cat a.py
def missing_doc(a: int, b: int = 2) -> int:
    """
    Missing doc

    Parameters
    ----------
    a : dict
        Azucar
    b : int, optional
        [default=2] Baron

    Returns
    -------
    int
    """
    return a + b

The current implemention outputs:

❯ pydoclint -q a.py
Loading config from user-specified .toml file: pyproject.toml
Found options defined in pyproject.toml:
{'style': 'numpy', 'exclude': '\\.git|\\.tox|tests|data', 'require_return_section_when_returning_
nothing': True, 'require_yield_section_when_yielding_nothing': False, 'treat_property_methods_as_
class_attributes': True, 'skip_checking_short_docstrings': False}
a.py
    1: DOC105: Function `missing_doc`: Argument names match, but type hints in these args do not 
match: a

And I expect a even more quiet version:

❯ pydoclint -q a.py
a.py
    1: DOC105: Function `missing_doc`: Argument names match, but type hints in these args do not 
match: a

So, --info would be the configuation and and config path, shown as "header":

❯ pydoclint -q a.py
Loading config from user-specified .toml file: pyproject.toml
Found options defined in pyproject.toml:
{'style': 'numpy', 'exclude': '\\.git|\\.tox|tests|data', 'require_return_section_when_returning_
nothing': True, 'require_yield_section_when_yielding_nothing': False, 'treat_property_methods_as_
class_attributes': True, 'skip_checking_short_docstrings': False}
jsh9 commented 1 month ago

So the messages come from these two lines:

https://github.com/jsh9/pydoclint/blob/81704368e3368c4f7b6d6ea6b16b163608579d65/pydoclint/parse_config.py#L39

and

https://github.com/jsh9/pydoclint/blob/81704368e3368c4f7b6d6ea6b16b163608579d65/pydoclint/parse_config.py#L74

I need to further learn how click passes config options. If you happen to be familiar with click, any help is welcome!

aemonge commented 1 month ago

I'll give a shot next week, I'm familiar with click. So for sure I'll archive it, just need some spare time :wink:

aemonge commented 3 weeks ago

I've done the happy path work -> https://github.com/jsh9/pydoclint/pull/178

The test are passing, checked using tox.

I didn't create a new test, since it needs to check for STDOUT and that a bit difficult to handle, if you need it I'll take my time and do it for you <3

Finally, I couldn't create a smoke test, since I don't know how to run the project locally (I'm more of a poetry dev, rather than a tox one). I've read the notes_for_developers.md but couldn't find a command to run this on ltye playground.py, if you can tell me how it would be lovely.