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
Conversation
include: Pattern[str], | ||
exclude: Pattern[str], | ||
extend_exclude: Optional[Pattern[str]], | ||
force_exclude: Optional[Pattern[str]], |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
This is a cleanup as was suggested by @ichard26 in #2005.