doc8 icon indicating copy to clipboard operation
doc8 copied to clipboard

doc8 ignores ''--config pyproject.toml" on Python 3.11

Open SerGeRybakov opened this issue 2 years ago • 7 comments

I have a number of reusable GitHub CI wokflows. One of them creates python environments of different versions and runs checks and tests.

The doc8 command is common for any environment: doc8 --config pyproject.toml ./docs

Here you can see 3 different jobs with 3.9, 3.10 and 3.11 (in the middle) environments: image

All the jobs, except 3.11 passed.

image image image

Pyproject.toml has the following simple setting:

[tool.doc8]  # RST linter
# https://github.com/PyCQA/doc8
max-line-length = 99

The length of each string is lower than 99.

I tried run doc8 locally on Python 3.11.4 by doc8 --config pyproject.toml ./docs and it also failed:

(py3.11) serge@dell:~/my_prj$ doc8 --config pyproject.toml docs/
Scanning...
Validating...
docs/index.rst:4: D001 Line too long
docs/index.rst:6: D001 Line too long
docs/index.rst:13: D001 Line too long
docs/index.rst:16: D001 Line too long
docs/index.rst:18: D001 Line too long
========
Total files scanned = 9
Total files ignored = 0
Total accumulated errors = 5
Detailed error counts:
    - doc8.checks.CheckCarriageReturn = 0
    - doc8.checks.CheckIndentationNoTab = 0
    - doc8.checks.CheckMaxLineLength = 5
    - doc8.checks.CheckNewlineEndOfFile = 0
    - doc8.checks.CheckTrailingWhitespace = 0
    - doc8.checks.CheckValidity = 0

SerGeRybakov avatar Aug 14 '23 10:08 SerGeRybakov

I also have this issue, but using --config setup.cfg. It seems the argument itself is ignored regardless of the configuration file format.

fmigneault avatar Aug 30 '23 23:08 fmigneault

@SerGeRybakov For the TOML file, try to install explicitly:

pip install tomli

That made it work for me with Python 3.11.2 and doc8 0.11.2 on Debian container, problem is in doc8 extract_config function and HAVE_TOML variable which is FALSE as it fails to import that module.

dmg0345 avatar Sep 04 '23 00:09 dmg0345

Error on my part for --config setup.cfg (works as expected). My error was only regarding a specific option (see #147 and #148).

fmigneault avatar Sep 05 '23 16:09 fmigneault

For me it is working for some commands (e.g. allow-long-titles = true and max-line-length = 1000) but ignore = "D001" is ignored and ignore-path-errors = "/home/user/VCS/project-1_23/doc/source/theory/kalman_filter/covariance_matrix_of_observation_noise_H.rst;D001" fails with

$ doc8 "/home/user/VCS/project-1_23/doc/source/theory/kalman_filter/covariance_matrix_of_observation_noise_H.rst" --config pyproject.toml
Traceback (most recent call last):
  File "/home/user/VCS/project-1_23/.venv/bin/doc8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 534, in main
    result = doc8(args)
             ^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 385, in doc8
    cfg = extract_config(args)
          ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 167, in extract_config
    cfg = from_toml(cfg_file)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 149, in from_toml
    value = parse_ignore_path_errors(value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 79, in parse_ignore_path_errors
    path, ignored_errors = path.split(";", 1)
    ^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

q-wertz avatar Feb 14 '24 10:02 q-wertz

For me it is working for some commands (e.g. allow-long-titles = true and max-line-length = 1000) but ignore = "D001" is ignored and ignore-path-errors = "/home/clemens/VCS/ads-b_simulator/doc/source/theory/kalman_filter/covariance_matrix_of_observation_noise_H.rst;D001" fails with

$ doc8 "/home/user/VCS/project-1_23/doc/source/theory/kalman_filter/covariance_matrix_of_observation_noise_H.rst" --config pyproject.toml
Traceback (most recent call last):
  File "/home/user/VCS/project-1_23/.venv/bin/doc8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 534, in main
    result = doc8(args)
             ^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 385, in doc8
    cfg = extract_config(args)
          ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 167, in extract_config
    cfg = from_toml(cfg_file)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 149, in from_toml
    value = parse_ignore_path_errors(value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/VCS/project-1_23/.venv/lib/python3.11/site-packages/doc8/main.py", line 79, in parse_ignore_path_errors
    path, ignored_errors = path.split(";", 1)
    ^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Try to have those settings as arrays in the toml file, e.g.:

ignore = ["D004"]
ignore-path = [".vscode"]

dmg0345 avatar Feb 14 '24 16:02 dmg0345

Thanks a lot. Works like a charm now for ignore = ["D001"]. :blush:

q-wertz avatar Feb 15 '24 10:02 q-wertz

for me not working at all, using

doc8 v1.1.1 python 3.11.5

woutervh avatar Mar 15 '24 11:03 woutervh