-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
--root
flag to specify project configuration (#160)
* Add `--root` flag to specify project configuration For #110 there are use cases where projects might have multiple pyproject.toml files in the repo for various configurations but we want to store all the `ufmt`/`usort`/`black` configuration in one place. Currently there is no easy way to do this without calling `ufmt` directly on the root of the project which can be super expensive in large projects. This adds a new flag so you can specify the root. This works well for the general configuration but I want to point out one area where it does not work correctly, specifically with excludes. Say you have this set up ``` $ ls ** pyproject.toml a: a.py pyproject.toml b: b.py $ cat pyproject.toml [tool.ufmt] excludes = [ "/a/", ] ``` all other files are empty. Then if you format the root you would expect only `b` to be formatted. If you format the `a` directory then `a.py` will get formatted currently as well. ``` $ ufmt --debug check . DEBUG ufmt.core Checking /private/tmp/project/b/b.py ✨ 1 file already formatted ✨ $ ufmt --debug check a DEBUG ufmt.core Checking /private/tmp/project/a/a.py ✨ 1 file already formatted ✨ ``` works as expected. the issue is now with the new flag in this PR, specifying the root and formatting directory `a` doesn't do what we expect ``` (.venv) [/tmp/project]$ ufmt --root=. --debug check a DEBUG ufmt.core Checking /private/tmp/project/a/a.py ✨ 1 file already formatted ✨ ``` The issue is that overriding the `root` here is insufficient, we would also need to tell `Trailrunner` about it too, see https://github.com/omnilib/trailrunner/blob/main/trailrunner/core.py#L170 So this flag will help with some configuration but it might be confusing in terms of the excludes unless we also patch the other library to allow you to set the root. * Use click.Path for validation --------- Co-authored-by: Amethyst Reese <amethyst@n7.gg>
- Loading branch information
1 parent
feeb1f2
commit bf2aea6
Showing
6 changed files
with
81 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters