Repository navigation
Allow valid targets alongside empty directories - #22177
nightcityblade wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
df7271d to
cbdd1f3
Compare
|
Fixed the Windows-only test expectation in 7d71289 by accepting both POSIX and drive-prefixed Windows separators. I also folded pre-commit.ci’s import-spacing auto-fix into the authored commit, preserving single-commit history. The focused 10-test suite passed before the formatting-only bot change; the final tree passes Ruff, ruff format, py_compile, and git diff --check. CI is rerunning. |
818d87f to
db5c22b
Compare
db5c22b to
7d71289
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Zocker1999NET
left a comment
There was a problem hiding this comment.
lgtm & should fix my issue. thanks for implementing that so fast ❤️
now only a maintainer decision is required for this change
| mod = os.path.basename(path) if options.scripts_are_modules else None | ||
| sources.append(BuildSource(path, mod, None)) | ||
| if not sources and empty_dirs: | ||
| raise InvalidSourceList(f"There are no .py[i] files in directory '{empty_dirs[0]}'") |
There was a problem hiding this comment.
Because multiple dirs can be supplied & the error now only occurs when all dirs are "empty", I would just list all dirs in the error:
| raise InvalidSourceList(f"There are no .py[i] files in directory '{empty_dirs[0]}'") | |
| empty_dirs_str = ", ".join(map(repr, empty_dirs)) | |
| raise InvalidSourceList(f"There are no .py[i] files in directories: {empty_dirs_str}") |
(and then also improve the escaping of the path strings, some Linux users have e.g. ' in their paths xD)
EDIT: This suggestion requires a small adaption on the test, because the message no longer matches because I used the plural directories.
|
Thanks for confirming the fix works for your issue and for the approval! |
Fixes #22173
create_source_list now defers the existing empty-directory error until all explicit targets have been scanned. This lets mypy check valid targets alongside an empty directory while preserving the fatal error when no sources are found.
A regression test covers both the mixed-target and all-empty cases.
Validation:
AI assistance: Codex helped draft the focused change and test; I reviewed the diff and ran all validation locally.