Repository navigation
fix: format standard input when in-place is set in the config file - #427
Merged
weibullguy merged 2 commits intoDec 3, 2026
Merged
Conversation
A config file with in-place = true made `docformatter -` exit with "--in-place cannot be used with standard input", even though the flag was not given on the command line. Drop the configured in-place mode when standard input is requested. An explicit --in-place with standard input still reports the error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #426
With
in-place = trueset in a config file, runningdocformatter -on standard input exited with "--in-place cannot be used with standard input", even though--in-placewas never given on the command line. Standard input has no file to rewrite, so the configured in-place mode is now dropped when standard input is requested. An explicit--in-place -on the command line still reports the error, so a real mistake is not hidden.Changes:
src/docformatter/configuration.py: when the files list includes-and--in-placewas not passed on the command line, the configured in-place value is cleared after argument parsing. The def line ofdo_parse_argumentsgets# noqa: PLR0915, because the added lines take it past ruff's 50-statement limit.tests/test_configuration_functions.py: two new tests. One checks that a config-only in-place setting still formats standard input. The other checks that an explicit--in-placewith standard input still exits with code 2 and the existing error message.How it was tested:
The full test suite under
tests/, run with the repo's pytest setup: 820 passed, 3 skipped.The two new tests passed. Without the fix, the config-only test fails and the explicit-error test still passes, as it guards existing behavior.
black and isort (check mode) on
srcanddocs/source/conf.py, ruff and pydocstyle onsrc, and mypy onsrcall passed.The repo's full pre-commit run was not executed here, because it needs network access to fetch its hooks. The lint box is left unchecked. The ruff, pydocstyle and other runs above are narrower than that run.
New tests added
Lint (repo pre-commit run not executed, see above)