PyCQA / doc8

Style checker for sphinx (or other) rst documentation.
https://github.com/PyCQA/doc8
Apache License 2.0
164 stars 36 forks source link

pyproject.toml tool.doc8.extension extends the extensions default value rather than replace it #143

Open dmg0345 opened 1 year ago

dmg0345 commented 1 year ago

When invoking doc8 if no --extension value is provided in the command line argument, doc8 uses the defaults of ['.rst', '.txt'] for this value, if the --extension command line argument is specified, its values are added to the defaults. When later it loads the configuration values from a pyproject.toml file in the tool.doc8.extension value, it will also extend the extensions with the values defined here.

Consider the following pyproject.toml:

[tool.doc8]
extension = [".rst", ".py"]

And the following call to doc8:

doc8 .

This will result in doc8 using [".rst", ".txt", ".rst", ".py"] instead of just the values in the pyproject.toml file [".rst", ".py"].

The following call:

doc8 . --extension '.bin'

Will result in [".rst", ".txt", ".bin", ".rst", ".py"] being used.

This behaviour is caused because of the append store action in the --extension parameter of argparse in main.py file, which appends to the default values specified for that parameter rather than replacing them, see issue https://bugs.python.org/issue16399.

In summary, there is no way to get rid of the default values for the extensions, [".rst", ".txt"] will be included no matter how you invoke doc8 or what configuration you provide.

Is this the intended behaviour?