--exclude flag to the command line

Bug #1481052 reported by asmeurer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
New
Undecided
Unassigned

Bug Description

I know that pyflakes doesn't want to add support for excluding errors inside of scripts, but would you be open to adding the --exclude flag to the pyflakes command to exclude files? My situation is this. I want to run pyflakes automatically in the test suite (on Travis CI). However, there are some files that should be ignored (e.g., a compat.py file with a bunch of Python 2/3 compatibility importat that pyflakes gives a bunch of unused import and undefined name warnings for, and a bundled library that uses * imports, but which I'd rather just leave alone). I tried using extended globbing in bash, but it seems it's not so easy to mix multiple !() globs, even with globstar enabled. Anyway, I couldn't figure out how to do it.

I know I can use flake8, but it seems that flake8 --select=F doesn't actually include all pyflakes errors (like syntax errors). I also kind of want to avoid flake8 just to reduce the temptation to test for pep8 errors.

Would it be OK to add --exclude, like flake8 and pep8, which excludes files or directories, to the flake8 command? The --exclude flag in flake8/pep8 accepts a comma separate list of values, which seems kind of dumb to me (it makes more sense to just accept files from the command line, like "pyflakes --exclude compat.py stuff/", which could then be globbed), but I'm OK with keeping it that way if cross-compatibility is a concern.

Revision history for this message
Ian Cordasco (icordasc) wrote :

If there's a bug in Flake8 then please report it there and we'll investigate. I think Phil has been leaning towards the "There's already a tool that does this" camp so I would guess adding --exclude here is a no-go.

Revision history for this message
John Vandenberg (jayvdb) wrote :

My vote is to not add this feature, and let flake8 do CLI niceties like this.

If you want to do it with raw pyflakes, at least on unix, the following patterns can be used if multiple globs are not working.

$ pyflakes `find . -name '*.py' -and -not -name package_name -and -not -name module_name.py`

or

$ find . -name '*.py' -and -not -name package_name -and -not -name module_name.py | xargs pyflakes

or

$ pyflakes `find . -name '*.py' | grep -v package_name | grep -v module_name.py`

grep -E might be better, depending on the globs you need to recreate as regex.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.