PyCQA / PyCQA/isort

`--filter-files` does not consider extensions

Open
#1,984 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

To reproduce:

$ mkdir -p folder
$ echo -e 'import unknown\nimport sys' > folder/file.py
$ isort folder --check -v
ERROR: folder/file.py Imports are incorrectly sorted and/or formatted.

Try filtering files with --gitignore and --filter-files - works fine.

$ echo '*.py' > folder/.gitignore
$ isort folder --check --gitignore
Skipped 1 files
$ isort folder/file.py --check --gitignore
ERROR: folder/file.py Imports are incorrectly sorted and/or formatted.
$ isort folder/file.py --check --gitignore --filter-files
Skipped 1 files

Try filtering files with --ext and --filter-files - works fine.

$ isort folder --check
ERROR: folder/file.py Imports are incorrectly sorted and/or formatted.
$ isort folder/file.py --check --ext txt
ERROR: folder/file.py Imports are incorrectly sorted and/or formatted.
$ isort folder/file.py --check --ext txt --filter-files
ERROR: folder/file.py Imports are incorrectly sorted and/or formatted.

I expected isort folder/file.py --check --ext txt --filter-files to have no filtered out the folder/file.py

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the isort CLI handling for --filter-files, --ext, and --gitignore, then run the reproduction commands from the issue to compare their filtering behavior. Done means a file whose extension is excluded by --ext is skipped when --filter-files is used, while the existing gitignore behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.