[feature request] .gitignore option for flake8
I would like if flake8 could ignore all files that match the .gitignore. This would be helpful since it is not ideal to list things that are specific to a specific dev environment in automatic test runners. Thanks, Austin
Austin Macdonald
I would like if flake8 could ignore all files that match the .gitignore.
Rather than making an option specific to one particular tool, I think the correct way to do this would be to break it in two: * Query $SOME_TOOL for a set of file names. In your case, this would be something like ‘git clean --dry-run -dX’. * Use the output from the above command to specify which files Flake should ignore. The ‘flake8’ help shows we have a ‘--exclude’ option available. So it remains only to transform the output from ‘determine-files-to-ignore’ into the format expected by ‘flake8 --exclude’. But please, not a special one-tool-only option. -- \ “Don't fight forces, use them.” —Richard Buckminster Fuller, | `\ _Shelter_, 1932 | _o__) | Ben Finney
On 2015-01-12 23:20, Ben Finney wrote:
Austin Macdonald
writes: I would like if flake8 could ignore all files that match the .gitignore.
Rather than making an option specific to one particular tool, I think the correct way to do this would be to break it in two:
* Query $SOME_TOOL for a set of file names. In your case, this would be something like ‘git clean --dry-run -dX’.
I use something like flake8 $(git ls-files|grep '^scripts\|\.py$'|grep ...) ls-files seems to have a lot of options, you might not even need grep.
On Mon, Jan 12, 2015 at 5:28 PM, Laurent Bachelier
On 2015-01-12 23:20, Ben Finney wrote:
Austin Macdonald
writes: I would like if flake8 could ignore all files that match the .gitignore.
Rather than making an option specific to one particular tool, I think the correct way to do this would be to break it in two:
* Query $SOME_TOOL for a set of file names. In your case, this would be something like ‘git clean --dry-run -dX’.
I use something like flake8 $(git ls-files|grep '^scripts\|\.py$'|grep ...)
ls-files seems to have a lot of options, you might not even need grep.
So I'm personally -1 on adding this feature to Flake8. There are a few reasons: 1. Already we support per-project and global configuration files for Flake8. In either (or both) of these we allow the user to specify things to ignore via --exclude. Ignoring things in git works similarly (i.e., per-repository and globally) and handling both cases (as would eventually be demanded) would be untenable, unmaintainable, and rather complex. 2. We can not (and will not) only support this feature for git. Supporting it for mercurial would be enough to satisfy me, but then we would sacrifice the ability to simply read a file for patterns (since mercurial allows for at least 2 ways (that I know of) to ignore files). 2. a. Shelling out to git and mercurial is extremely sub-optimal and subprocesses introduce yet another group of hacks to support on both Windows, OS X, and Linux (already complicated by using multiprocessing). 2. b. Git has no elegant API for this 2. c. Using Mercurial's API (according to Mercurial) would probably made Flake8 would have to be re-licensed as a GPL-family tool, which is unacceptable. 3. This can already quite easily be configured (globally or per-project) but would require maintaining a .gitignore and a second configuration file. 4. People may expect that some file which should not be checked in is still compliant. Automatically ignoring it because it is ignored by a *separate* tool will lead to confusion and likely bug reports. 5. Explicit is better than magic. If you want Flake8 to ignore something, there are already well documented ways of doing so. Flake8 doesn't automatically check commit diffs for you either, nor will it. It /will/ install a hook for you but it won't do it without your consent. Adding this would violate internal consistency. There may be value in a separate extension to /suggest/ patterns or files to pass to --exclude based on VCS ignore files though. I encourage others to continue offering solutions for their various tools. We can turn them into snippets over on https://gitlab.com/pycqa/flake8/snippets Cheers, Ian
participants (4)
-
Austin Macdonald
-
Ben Finney
-
Ian Cordasco
-
Laurent Bachelier