Skip to content

Respect file extensions with --filter-files - #2707

Closed
yuefdev wants to merge 1 commit into
PyCQA:mainfrom
yuefdev:fix-filter-files-extensions
Closed

yuefdev wants to merge 1 commit into
PyCQA:mainfrom
yuefdev:fix-filter-files-extensions

Conversation

@yuefdev

@yuefdev yuefdev commented Oct 3, 2026

Copy link
Copy Markdown

Fixes #1984.

--filter-files applies skip rules to explicitly supplied files but ignores supported extensions. Consequently, isort example.py --filter-files --ext txt --check still checks the Python file and can exit with an error.

Apply the existing is_supported_filetype check to file arguments during filtering. Directories continue through normal discovery, and explicitly supplied files without --filter-files retain their existing behaviour.

Regression tests cover explicit files, directory discovery, check mode, and the unfiltered case. Two new cases fail before the fix.

Validation:

  • python -m pytest tests/unit/test_main.py tests/unit/test_settings.py -q --tb=short --show-capture=no: 57 passed, 1 skipped.
  • Ruff lint/format and mypy isort/main.py passed.

AI assistance: Codex prepared this fix and regression coverage and ran the checks above. No independent human review is claimed.

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.

--filter-files does not consider extensions

2 participants