Skip to content

add --force-exclude argument#1032

Merged
JelleZijlstra merged 15 commits into
psf:masterfrom
itajaja:fix-438
May 8, 2020
Merged

add --force-exclude argument#1032
JelleZijlstra merged 15 commits into
psf:masterfrom
itajaja:fix-438

Conversation

@itajaja

@itajaja itajaja commented Sep 24, 2019

Copy link
Copy Markdown
Contributor

fixes #438

I Have not added or amended tests yet, but if we agree on the approach, I can work on them

@itajaja

itajaja commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

ping, I think this would help a lot of people :)

@itajaja itajaja changed the title honor exclude when specifying file path add --force-exclude argument Mar 3, 2020
@RCM7

RCM7 commented Apr 17, 2020

Copy link
Copy Markdown

+1 this would definitely help! @ambv Any chance you will find the time to take a look?
Is there anything we can help with?

@yukw777

yukw777 commented Apr 27, 2020

Copy link
Copy Markdown
Contributor

+1

@itajaja do you need any help with the lint failure?

@itajaja

itajaja commented Apr 27, 2020

Copy link
Copy Markdown
Contributor Author

if you want to help, you are welcome to. I am honestly tired of trying to get this merged. black team has been pretty unresponsive about this 🤷

@jimmy927

Copy link
Copy Markdown

I can't understand why this is still pending, without this i basically cant make black work together with pycharm.

@yukw777

yukw777 commented Apr 28, 2020

Copy link
Copy Markdown
Contributor

@itajaja here's a PR that fixes the lint issue: itajaja#1 Hopefully this will move things forward.

@itajaja

itajaja commented Apr 29, 2020

Copy link
Copy Markdown
Contributor Author

@ambv any chance you can have a look at this?

#438 (comment) I am holding you accountable! :P

@yukw777

yukw777 commented May 4, 2020

Copy link
Copy Markdown
Contributor

Ping! @ambv

@yukw777

yukw777 commented May 4, 2020

Copy link
Copy Markdown
Contributor

I'm not sure why the travis ci job is failing.. coverage run tests/test_black.py passes on this branch on my laptop.

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long wait here! I have a few comments.

Comment thread black.py Outdated
re_compile_maybe_verbose(force_exclude) if force_exclude else None
)
except re.error:
err(f"Invalid regular expression for exclude given: {exclude!r}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should say force_exclude, not exclude.

Comment thread black.py Outdated
p.iterdir(),
root,
include_regex,
exclude_regex,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should also obey the force_exclude_regex. It will be surprising if I force-exclude a file and it gets included anyway because it's in a directory I included.

@JelleZijlstra JelleZijlstra self-assigned this May 8, 2020
@JelleZijlstra

Copy link
Copy Markdown
Collaborator

Working on making my own requested changes now

@jimmy927

jimmy927 commented May 8, 2020

Copy link
Copy Markdown

I can do QA on this one if needed in a more complex devel-environment no ensure desired workflow can be achieved.

@cooperlees

Copy link
Copy Markdown
Collaborator

I can do QA on this one if needed in a more complex devel-environment no ensure desired workflow can be achieved.

Please sir. With your confidence we'd look to merge this today!

@JelleZijlstra

Copy link
Copy Markdown
Collaborator

@jimmy927 that'd be great! Please let me know if you notice anything amiss.

@jimmy927

jimmy927 commented May 8, 2020

Copy link
Copy Markdown

@jimmy927 that'd be great! Please let me know if you notice anything amiss.

Can i just check out the repo and run it as is ?
Or are there any build artefacts that i need ?

@JelleZijlstra

Copy link
Copy Markdown
Collaborator

@jimmy927 yes, you can check out the repo and run black.py, although you may have to install dependencies (maybe with pip install -e . in the Black repo).

@JelleZijlstra

Copy link
Copy Markdown
Collaborator

OK CI is finally green. I ended up making a few more changes:

  • Split off a get_sources() function because flake8 thought main got too complex
  • Make gitignore matching look at the relative path of the file, so we don't get bitten by the fact that Travis runs CI in a directory called build.
@JelleZijlstra JelleZijlstra merged commit 89c87d2 into psf:master May 8, 2020
@itajaja

itajaja commented May 8, 2020

Copy link
Copy Markdown
Contributor Author

nice!

@itajaja itajaja deleted the fix-438 branch May 8, 2020 14:53
@berkowitzi

Copy link
Copy Markdown

@JelleZijlstra are there plans to cut a release with this improvement?

@jimmy927

jimmy927 commented Jul 6, 2020

Copy link
Copy Markdown

@JelleZijlstra are there plans to cut a release with this improvement?

you can do the following in the meantime:

pip install git+git://github.com/psf/black.git

then find your env and run the bin, it should look like this:

(black) ➜  black ./bin/black --version
black, version 19.10b1.dev126+g11f130b
@jimmy927

jimmy927 commented Jul 6, 2020

Copy link
Copy Markdown

@jimmy927 yes, you can check out the repo and run black.py, although you may have to install dependencies (maybe with pip install -e . in the Black repo).

Works great!
Tested with pycharm now!

see config:

Screenshot 2020-07-06 at 22 00 23

@Saksow

Saksow commented Jan 5, 2021

Copy link
Copy Markdown

We would be happy to use force-exclude in pyproject.toml using a black release. We are using black with pre-commit and want to consolidate all configs inside pyproject.toml. How do I track this to be released?

@ichard26

ichard26 commented Jan 9, 2021

Copy link
Copy Markdown
Collaborator

@Saksow if I'm not misremembering, --force-exclude is available in Black version 20.8b1 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

9 participants