-
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
Assert statement condition broken up in unfortunate way #348
Comments
Black prefers to split using existing bracket pairs compared to putting extra parentheses itself. This usually looks better but in your case I agree it would look a bit better formatted as: ...
assert (
len(ufo_order) == len(ot_order)
), "{}, subsetting: amount of glyphs does not match with {}".format(
ufo.path, otf_path
) I'll look into what I can do to improve this. Changes to this do end up touching unexpected formattings elsewhere so I'm trying to be conservative about this. |
Found another unfortunate break-up:
Might be better as:
|
Your second example is a duplicate of #260. In essence, Black doesn't understand symmetry and to make it understand symmetry it will slow things down significantly so I have to be smart about it. We'll address it some day but there are clearer bugs that I'll have to get to first. |
Here's a playground for convenience. It formats it differently this time around: assert len(ufo_order) == len(
ot_order
), "{}, subsetting: amount of glyphs does not match with {}".format(ufo.path, otf_path) Although personally I'd like to have it like this: assert (
len(ufo_order) == len(ot_order),
"{}, subsetting: amount of glyphs does not match with {}".format(ufo.path, otf_path)
) which is just barely below the line length limit, but reformatted to: assert (
len(ufo_order) == len(ot_order),
"{}, subsetting: amount of glyphs does not match with {}".format(
ufo.path, otf_path
),
) because of a trailing comma that would be added that would get it over the limit 😄 which is ok too in my opinion. |
The second example is still being discussed in #2156 |
Woah let's pull some brakes with the style I proposed: assert (
# condition explosion
), (
# msg explosion
) |
FWIW, |
Yeah, that was poorly worded, thanks for the clarification! |
Operating system: Win 10 1803 x64
Python version: 3.6.5
Black version: 18.6b2
Does also happen on master: yes
Black outputs the following code in one project (googlefonts/fontmake@e22a624):
The placement of the assert condition is unfortunate... Is this expected? Is there a more elegant way to write that code?
The text was updated successfully, but these errors were encountered: