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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aDeprecationWarning
.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.