python-black icon indicating copy to clipboard operation
python-black copied to clipboard

Support for extend-exclude

Open MikesAtMIT opened this issue 2 years ago • 3 comments

I was trying to use this plugin, but it seems like the extend-exclude option in a pyproject.toml file is not honored. When I run black from the command line, it is honored, so it seems like it's just that the plugin doesn't handle the option? Any chance that could be added?

MikesAtMIT avatar Oct 19 '23 21:10 MikesAtMIT

Actually, I think maybe the option that needs to be supported is force-exclude since running on save would pass the name of the file to black, per this post https://stackoverflow.com/a/73296261. When I use force-exclude, the toml behaves as expected when using VSCode, but I prefer Sublime so hoping to get support for this

MikesAtMIT avatar Oct 19 '23 23:10 MikesAtMIT

Adding this feature requires changing quite a lot of code. If you are interested in submitting a pull request, it may get done faster. Otherwise it may take many days to complete in my spare time.

thep0y avatar Oct 22 '23 10:10 thep0y

Ok, thanks for responding. We ended up just deciding to not exclude files from black at all and changed our toml. The main issue was trying to exclude files that were auto-generated (like django migration files) because most are never edited and so would never trigger black in Sublime. But if they are ever edited and then formatted by black, they generate large diffs that are then hard to separate real changes from formatting changes. We solved it by using precommit to just force formatting on all new files.

Still, perhaps this feature would be useful to others. I saw the commit you just added yesterday. If you are going to add this feature, I'd add force-exclude specifically. For the use case where you are having the plugin run black on save for the open file, exclude and extend-exclude appear to be ignored because you're specifying a file, which I guess overrides those exclude params. But force-exclude will always be honored.

MikesAtMIT avatar Oct 23 '23 14:10 MikesAtMIT