docformatter
docformatter copied to clipboard
Incorrect pyproject.toml parsing of boolean values (e.g., for `--pre-summary-space`)
Both in the current github version (1def3c4) and the released PyPI version (v1.5.0) I get a unexpected behavior when configuring docformatter
via the pyproject.toml
file.
Test plan
cat > pyproject.toml << EOF
[tool.docformatter]
pre-summary-space = false
EOF
cat > test.py << EOF
class Test():
"""Foo bar."""
EOF
docformatter --version
docformatter --config pyproject.toml test.py
Additional context:
python -c "import docformatter.configuration; print(docformatter.configuration.TOMLI_INSTALLED)"
True
Expected output
No change. The file is already correctly formatted.
Actual output
A space is added in front of the summary line, which was disabled
docformatter 1.5.0
--- before/test.py
+++ after/test.py
@@ -1,3 +1,3 @@
class Test():
- """Foo bar."""
+ """ Foo bar."""
Investigation and work-around
There seems to be sth off with argument parsing. The error can be fixed by using the False
defaults for pre-summary-space
which was added in 1def3c4, i.e. this works:
cat > pyproject.toml << EOF
[tool.docformatter]
EOF
cat > test.py << EOF
class Test():
"""Foo bar."""
EOF
docformatter --config pyproject.toml test.py
and does not change the file. Note, this fix is not possible on the pypi version as the default for pre-summary-space
is True
there.
This seems to happen with other options as well. Setting any of the following actually has the opposite effect.
pre-summary-newline = false
pre-summary-multi-line = false
blank = false
This is not limited to boolean. I tried wrap-summaries = 12
and it didn't wrap anything.