autopep8 icon indicating copy to clipboard operation
autopep8 copied to clipboard

Precedence of excluding vs. including files

Open tedmiston opened this issue 8 years ago • 3 comments

In trying to help answer someone's question on Stack Overflow, I came across what may be a bug, or perhaps just something that's unclear to me.

The full details are here on SO, but I've copied below for your convenience.

Also here are the details requested in the contributor guidelines:

$ autopep8 --version
autopep8 1.2.4

$ pep8 --version
1.7.0

$ python --version
Python 2.7.11

$ uname -a
Darwin <my machine name> 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

To create this setup, I simply ran mktmpenv followed by pip install autopep8.

This style to avoid specific files works for me (using either single or double quotes):

autopep8 --diff --recursive --exclude="*.styl" .

This also works:

autopep8 --diff --exclude="*.styl" *.py

However this does not exclude .styl files:

autopep8 --diff --exclude="*.styl" *

In my opinion, it appears [OP has] identified a bug in autopep8.

However, perhaps it's not a bug, but rather an opinionated decision that star inclusion should take precedence over star exclusion.

In other words, is running this command intended to process (a) all files, or (b) no files?

autopep8 --diff --exclude="*" *

tedmiston avatar Jun 10 '16 23:06 tedmiston

I think I originally meant for --exclude to be used with --recursive only. But I see how this might be unintuitive. In any case, pep8/pycodestyle does things the way you and the Stack Overflow question expects. So I think it would make sense to fix this. At the very least, this would make our tools match in behavior.

Thanks

myint avatar Jun 11 '16 14:06 myint

Thanks so much for the clarification. Admittedly an edge case, but I appreciate taking the time to address it. Thank you!

tedmiston avatar Jun 11 '16 18:06 tedmiston

I fall into this case also. Just for the record, to launch the tool only against .py files I execute the tool two times in this way:

autopep8 --diff --recursive **/*.py
autopep8 --diff --recursive *.py

fpuga avatar Jul 14 '17 11:07 fpuga