-
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
Simplify code in lines.py #4167
Conversation
This has been getting a little messy. These changes neaten things up, we don't have to keep guarding against `self.previous_line is not None`, we make it clearer what logic has side effects, we reduce the amount of code that tricky `before` could touch, etc
src/black/lines.py
Outdated
if current_line.is_decorator or current_line.is_def or current_line.is_class: | ||
if not current_line.is_decorator: | ||
self.previous_defs.append(current_line) |
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.
if current_line.is_decorator or current_line.is_def or current_line.is_class: | |
if not current_line.is_decorator: | |
self.previous_defs.append(current_line) | |
if current_line.is_def or current_line.is_class: | |
self.previous_defs.append(current_line) |
This should be equivalent unless I'm missing something
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.
Thanks, fixed. Logic was previously inside _maybe_empty_lines_for_class_or_def
and I'd just copied the guard around that function call.
This has been getting a little messy. These changes neaten things up, we don't have to keep guarding against `self.previous_line is not None`, we make it clearer what logic has side effects, we reduce the amount of code that tricky `before` could touch, etc
This has been getting a little messy. These changes neaten things up, we don't have to keep guarding against
self.previous_line is not None
, we make it clearer what logic has side effects, we reduce the amount of code that trickybefore
could touch, etcThis change is intended to be a no-op