Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary arguments to Black #351

Open
akaihola opened this issue Apr 1, 2022 · 2 comments
Open

Allow arbitrary arguments to Black #351

akaihola opened this issue Apr 1, 2022 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@akaihola
Copy link
Owner

akaihola commented Apr 1, 2022

Arbitrary arguments to Black aren't yet supported.

Darker invokes Black directly through its internal Python API. The Black configuration is actually first read by Darker, and some options are passed on to Black. But for example --preview isn't currently one of those options, while it would be useful for some use cases (see #350).

We should implement support for e.g. --black-options="--preview ..." to allow passing arbitrary extra arguments to Black. An alternative name would be --extra-black-options="..." – this is to be decided.

It's unclear whether it's possible to easily pass all options in --black-options="..." when calling Black via its Python API. If not, that may ruin the whole idea.

This is a bit related to #244, too.

Originally posted by @akaihola in #350 (comment)

@brtkwr
Copy link

brtkwr commented Apr 19, 2022

I configured black to ignore a folder but darker pre-commit hook doesn't appear to be ignoring changes to that folder. Is this expected? Config option to do this would be handy.

@akaihola
Copy link
Owner Author

akaihola commented Apr 20, 2022

@brtknr, if that's the case, we should investigate.

If you run Black in a pre-commit hook with a similar folder ignore configuration, does it ignore that folder?

If pre-commit calls Darker separately for each file, it shouldn't respect Black's file/folder ignore configuration. But in that case I would think Black shouldn't work either, since I'm pretty sure I tried to mirror Black's behavior here.

Related changes in Darker:

#146 was fixed in #171 and released in version 1.3.0:

Skip reformatting files set to be excluded by Black in configuration files.

#104 was fixed in #215 and released in version 1.3.2.

Change log entry:

Honor exclusion patterns from Black configuration when choosing files to reformat. This only applies when recursing directories specified on the command line, and only affects Black reformatting, not isort or linters.

PR description:

Unify exclusion behavior with Black: the exclude options from Black configuration only apply to directories listed on the command line, but not to files. Closes #104.

@akaihola akaihola modified the milestones: 1.6.0, 1.6.1 Dec 19, 2022
@akaihola akaihola added the question Further information is requested label Dec 25, 2022
@akaihola akaihola modified the milestones: 1.6.1, 1.8.0 Dec 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Development

No branches or pull requests

2 participants