Add --exclude-base-dir, defaults to the pyproject.toml directory #631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Add --exclude-base-dir which defaults to the location of
pyproject.tomlso thatexclude paths are always made relative to this path.
For some context:
Currently there is a problem where the
excludedirectories listed inpyproject.tomlare 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
excludelist. Checkingvscode, it's passing full paths toautopep8by 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.tomlwhich are relative to that fileThis PR sets
exclude-base-dirto 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-diras a user visible argument, this could be a global instead.