-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Zero length stdin input causes black to fail (regression) #2337
Comments
I feel the opposite here and that we were broken before and this is now fixed. We should error when nothing is piped in. It will allow people to optimize their calls sending empty strings and save those resources from starting black for no reason. I feel your CI script should check if the file is empty before trying to pipe it into black. Edit: That said, I can see expectations here due to other Unix CLI tool behavior tho. So we should do what majority thinks is right here.
|
That's a fair point, but not immediately obvious at least to me. The error happens when manually inputting an empty stream as well. At the very least, I think "string index out of range" is not the error we want to be throwing. If we want to restrict to nonempty inputs, maybe it should read "cannot format empty stream" or something like that. Thoughts? |
I think we should allow this, since Unix tools generally accept empty input (e.g. cat, grep, awk). |
May I work on this? |
Please do! |
Describe the bug
Using latest version 21.6b0 piping an empty file into black as below causes "string index out of range". This is a regression from 21.5b2.
NOTE: referencing an empty file works as expected this is only when piping into - as example below.
i.e. this works:
To Reproduce
Expected behavior
Using stdin with empty file works as previous version without error.
Environment (please complete the following information):
Does this bug also happen on main?
Yes
Additional context
A bit of a tails case but we're using this approach within a CI script.
The text was updated successfully, but these errors were encountered: