Skip to content

fix: format standard input when in-place is set in the config file - #427

Merged
weibullguy merged 2 commits into
PyCQA:masterfrom
shashank11yadav:fix/stdin-config-in-place
Dec 3, 2026
Merged

weibullguy merged 2 commits into
PyCQA:masterfrom
shashank11yadav:fix/stdin-config-in-place

Conversation

@shashank11yadav

Copy link
Copy Markdown
Contributor

Fixes #426

With in-place = true set in a config file, running docformatter - on standard input exited with "--in-place cannot be used with standard input", even though --in-place was 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-place was not passed on the command line, the configured in-place value is cleared after argument parsing. The def line of do_parse_arguments gets # 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-place with 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 src and docs/source/conf.py, ruff and pydocstyle on src, and mypy on src all 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)

shashank11yadav and others added 2 commits November 30, 2026 08:13
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.
@weibullguy
weibullguy merged commit 6a09150 into PyCQA:master Dec 3, 2026
7 checks passed
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

Successfully merging this pull request may close these issues.

fix: docformatter - fails with "--in-place cannot be used with standard input" when in-place = true is in the config file

2 participants