Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
SerGeRybakov opened this issue Aug 14, 2023 · 7 comments
Open

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

SerGeRybakov opened this issue Aug 14, 2023 · 7 comments

Comments

@SerGeRybakov
Copy link

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
@fmigneault
Copy link
Contributor

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

fmigneault added a commit to Ouranosinc/Magpie that referenced this issue Aug 31, 2023
@dmg0345
Copy link

dmg0345 commented Sep 4, 2023

@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.

@fmigneault
Copy link
Contributor

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

@q-wertz
Copy link
Contributor

q-wertz commented Feb 14, 2024

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)

@dmg0345
Copy link

dmg0345 commented Feb 14, 2024

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"]

@q-wertz
Copy link
Contributor

q-wertz commented Feb 15, 2024

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

@woutervh
Copy link

for me not working at all, using

doc8 v1.1.1
python 3.11.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants