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

Turn test_regex into a click callback #2016

Merged
merged 2 commits into from Mar 3, 2021
Merged

Conversation

thejcannon
Copy link
Contributor

This is a cleanup as was suggested by @ichard26 in #2005.

include: Pattern[str],
exclude: Pattern[str],
extend_exclude: Optional[Pattern[str]],
force_exclude: Optional[Pattern[str]],
Copy link
Contributor Author

@thejcannon thejcannon Mar 1, 2021

Choose a reason for hiding this comment

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

This method doesn't start with an underscore (as don't the others) which makes me question the intended visibility of this method (is it public or private? do we expect people to know not to use it if it's private?).

If you'd like I'd be happy to handle str params here for backwards-compatibility and issue a DeprecationWarning.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly, I have no idea whether people use this function (I hope not since it certainly wasn't designed for it!), but even though Black technically doesn't have a public API, I bet we're going to hit Hyrum's Law. My personal opinion is that since it's that since it needs a click context anyway and has some behaviour API consumers wouldn't like (like exiting without a choice in some cases), it's fine to just leave this change unmitigated. Others may have a different opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good point about the click context object!

FWIW you could easily add underscores to everything to imply everything is private. Then if people really want to use it they'll have to fight their linters. You also get some deniability when people inevitably complain "you broke me!".

However, I think you'll have to be choosy about what to initially mark private, as I feel like I've seen people consuming black from Python in the wild.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine to change the API here. We already don't guarantee a public API, and as @ichard26 says this function is already quite inconvenient to use as an API.

Copy link
Collaborator

@ichard26 ichard26 left a comment

Choose a reason for hiding this comment

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

Just a little nit and I'm approving. Thanks for the PR!

src/black/__init__.py Outdated Show resolved Hide resolved
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
@JelleZijlstra JelleZijlstra merged commit e3c71c3 into psf:master Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants