Add --exclude-base-dir which defaults to the location of pyproject.toml so that
exclude paths are always made relative to this path.
For some context:
Currently there is a problem where the exclude directories listed in pyproject.toml are compared against paths which depend on the command line input given.
I ran into this when attempting to use autopep8 to format all source files in a project and noticed that:
autopep8 .
Worked, while:
autopep8 $PWD
Failed to exclude directories.
This isn't a problem when executing from the command line however IDE's may pass in full paths which then fail to match the paths in the exclude list. Checking vscode, it's passing full paths to autopep8 by default (for example).
The problem is that when the full directory is passed in, this then expands to an absolute path that doesn't match the paths in the pyproject.toml which are relative to that file
This PR sets exclude-base-dir to the base directory of the pyproject.toml, so exclude checks first make paths relative to this directory before matching. The "." is added at the beginning of paths not to break compatibility with anyone already depending on the current behavior of autopep8 ..
Note that I'm not so keen on exposing --exclude-base-dir as a user visible argument, this could be a global instead.
Add --exclude-base-dir which defaults to the location of
pyproject.toml
so that exclude paths are always made relative to this path.For some context:
Currently there is a problem where the
exclude
directories listed inpyproject.toml
are compared against paths which depend on the command line input given.I ran into this when attempting to use autopep8 to format all source files in a project and noticed that:
Worked, while:
Failed to exclude directories.
This isn't a problem when executing from the command line however IDE's may pass in full paths which then fail to match the paths in the
exclude
list. Checkingvscode
, it's passing full paths toautopep8
by default (for example).The problem is that when the full directory is passed in, this then expands to an absolute path that doesn't match the paths in the
pyproject.toml
which are relative to that fileThis PR sets
exclude-base-dir
to the base directory of thepyproject.toml
, so exclude checks first make paths relative to this directory before matching. The "." is added at the beginning of paths not to break compatibility with anyone already depending on the current behavior ofautopep8 .
.Note that I'm not so keen on exposing
--exclude-base-dir
as a user visible argument, this could be a global instead.