-
Notifications
You must be signed in to change notification settings - Fork 2
Make use of the black code formatter #33
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
Conversation
cbefus
left a comment
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.
Overall it seems like a pretty minimal change and will force continued consistency going forward. I am on board. Some discussion about formatting before we merge. This is also just a "for the devs" change so I wont need a version/deploy.
| value = optional.if_present(some_thing_consumer).or_else(or_else_procedure) | ||
| assert scope['if_seen'] | ||
| assert not scope['else_seen'] | ||
| value = optional.if_present(some_thing_consumer).or_else( |
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 assume we did a line break here because of the new 80 character limit? My preference would be:
value = \
optional.if_present(some_thing_consumer) \
.or_else(or_else_procedure)This formatting ensures that the readers eye always sees the indented level as directly (or as closely as possible) subbed to the item it relates.
Off this explanation I also get people on my team doing things like:
value = \
optional \
.if_present(some_thing_consumer) \
.or_else(or_else_procedure)I dont mind this, as I think it reads really easy, but something about that lone optional \ is a bit strange.
Thoughts?
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 wonder if black can be configured like this. It presents itself as an 'opinionated' formatter.
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 could pull and try and figure it out but I am pretty impartial on linters. I can live with the above formatting if its not configurable. Curious about your preferences on the above styles though.
| optional = Optional.empty() | ||
| with pytest.raises(TestException): | ||
| optional.if_present(lambda x: x).or_else_raise(TestException("Something")) | ||
| optional.if_present(lambda x: x).or_else_raise( |
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.
similar comment to above about formatting.
|
|
||
| optional.if_present(some_thing_consumer).or_else_raise(ShouldNotHappenException) | ||
| assert scope['seen'] | ||
| optional.if_present(some_thing_consumer).or_else_raise( |
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.
as above.
|
|
||
|
|
||
| CompatibleABC = ABCMeta('ABC', (object,), {'__slots__': ()}) | ||
| CompatibleABC = ABCMeta("ABC", (object,), {"__slots__": ()}) |
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 like that it prefers double quotes to single, this has always been my preference. For some reason I feel it has been historically anti-pythonic though.
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.
You can tell black to skip string normalization and it will leave single quoted strings as they are. It prefers doubles as text is more likely to include an apostrophe or single quote than a double quote.
d80fd54 to
e58cca2
Compare
e58cca2 to
da0c753
Compare
Worth a look.
https://black.readthedocs.io/en/stable/