Skip to content

fix: return exit code 0 when no Python files are found - #361

Open
Sanjays2402 wants to merge 1 commit into
PyCQA:masterfrom
Sanjays2402:fix/no-python-files-exit-code
Open

fix: return exit code 0 when no Python files are found#361
Sanjays2402 wants to merge 1 commit into
PyCQA:masterfrom
Sanjays2402:fix/no-python-files-exit-code

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #348

Since v1.7.8, do_format_files() counted "no Python files were processed" as an error, so docformatter example.txt or docformatter -cr . on a tree with no Python files exits 1 and breaks CI pipelines that passed on 1.7.7.

The is_empty branch now only reports an error when a path passed on the command line does not exist, so the missing-file exit code 1 is preserved while an empty-but-valid set of inputs is a no-op. New test_no_python_files_exit_code fails on master (exit 1) and passes with the fix; the existing test_io_error_exit_code still passes.

Since v1.7.8 docformatter exits 1 whenever no Python file was processed,
so running it on a non-Python file, or recursively over a directory that
happens to contain no Python files, fails CI pipelines that used to pass
on v1.7.7.

The unconditional 'is_empty -> error' branch in do_format_files() now
only reports an error when a path given on the command line does not
exist, preserving the existing missing-file exit code 1 while making an
empty but valid set of inputs a no-op.

Closes PyCQA#348
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.

docformatter v1.7.8 now returns exit code 1 when run against non-Python files

1 participant