docformatter: Wrong admonition reformat on `v1.6.0.rc1`
I am using docformatter 1.5.0 for a couple of month now by invoking the following CLI, which always worked fine:
$ docformatter --recursive --in-place --wrap-summaries 88 --wrap-descriptions 88 .
In order to test for the fix for #140, I updated to v1.6.0.rc1. Now the same call with the same parameters always exits with error code 3. See the log from my GitHub action:
$ docformatter --recursive --in-place --wrap-summaries 88 --wrap-descriptions 88 .
(...)
Error: Process completed with exit code 3.
How to reproduce
First, install v1.6.0.rc1:
$ pipx install git+https://github.com/PyCQA/docformatter.git@v1.6.0.rc1
installed package docformatter 1.5.1, installed using Python 3.11.1
These apps are now globally available
- docformatter
done! ✨ 🌟 ✨
$ docformatter --version
docformatter 1.5.0
BTW, notice how the package is reported as 1.5.1 by pipx and 1.5.0 by docformatter itself. This is a confusing issue due to the 1.6.0.rc1 version string not being set in the development branch. Inspecting the code reveal pipx is perfectly doing its job and that’s really is the v1.6.0.rc1 branch code we are running. For proof, the presence of the URL_PATTERNS constant that was added in commit 917fed92248d1fb91a1f4da61b5aaaec7367fe23:
$ grep -A 4 'URL_PATTERNS =' ~/.local/pipx/venvs/docformatter/lib/python3.11/site-packages/docformatter/syntax.py
URL_PATTERNS = (
"afp|"
"apt|"
"bitcoin|"
"chrome|"
Now that we run 1.6.0.rc1, let’s download a minimal file from my project:
$ wget "https://raw.githubusercontent.com/kdeldycke/click-extra/86991e4023a962ff14e0ec774e534e118ad3b56e/click_extra/platform.py"
(...)
2023-01-24 (11.3 MB/s) - ‘platform.py’ saved
And run docformatter on it:
$ docformatter --recursive --in-place --wrap-summaries 88 --wrap-descriptions 88 ./platform.py
$ echo $?
3
Hypothesis
If we run the same command as above, on the same file, with the extra --diff parameter, we get:
$ docformatter --recursive --in-place --wrap-summaries 88 --wrap-descriptions 88 --diff ./platform.py
--- before/./platform.py
+++ after/./platform.py
@@ -21,9 +21,9 @@
.. warning::
- ``click_extra.platform`` is deprecated since version 3.8.0.
+``click_extra.platform`` is deprecated since version 3.8.0.
- Use ``click_extra.platforms`` (with a trailing ``s``) instead.
+Use ``click_extra.platforms`` (with a trailing ``s``) instead.
"""
import warnings
$ echo $?
3
Is the strange reformatting, which doesn’t seems to recognize the .. warning:: admonition, can explain the constant exit with code 3?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 26 (9 by maintainers)
Commits related to this issue
- Skips docformatter 1.5.x and 1.6.0rc1. Refs: https://github.com/PyCQA/docformatter/issues/157 Reverts: 95a2c92cf0e71205f8c413d3970b2c9c183669b3 3a061368e43b824c90e26508e8942a2dc4b1e746 — committed to kdeldycke/workflows by kdeldycke a year ago
- Use docformatter v1.6.0-rc2 to fix admonitions. Refs: https://github.com/PyCQA/docformatter/issues/157 https://github.com/PyCQA/docformatter/issues/127 — committed to kdeldycke/workflows by kdeldycke a year ago
- Bump to docformatter 1.6.0-rc6. Refs: https://github.com/PyCQA/docformatter/issues/157#issuecomment-1457418784 — committed to kdeldycke/workflows by kdeldycke a year ago
@kdeldycke v1.6.0-rc6 is available.
To keep the summary on the line after the
""", you’d need to pass the--pre-summary-newlineargument. However, that’s global. But, the.being added aftersnippetis the result of it being recognized as the summary line. I’ll look into that.Agreed, shouldn’t do this. I’m on it.
@kdeldycke OK. I added a function to find and ignore reST directives (for now). Once I get all this URL business straightened out, I’ll start working on docformatter actually handling reST directives properly. In the meantime, you can try
v1.6.0-rc3and see if there’s any improvement.Also, are you OK with me using some of your docstrings as test inputs?