-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Ignore all magics #6
base: master
Are you sure you want to change the base?
Conversation
Fix: Ignore all magic calls.
Fix: Ignore all magic calls.
@@ -37,10 +37,21 @@ def black(self, line, cell): | |||
args = magic_arguments.parse_argstring(self.black, line) | |||
line_length = args.line_length | |||
if cell: | |||
formated = format_str(src_contents=cell, line_length=line_length) | |||
if formated and formated[-1] == "\n": | |||
# Comment magics |
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.
Shall we leave a detailed comment on:
- Pattern the regex replacing and what it is replacing it with.
- Give an example.
# Comment magics | ||
cell = re.sub(r"^%", r"##!%", cell) | ||
cell = re.sub(r"\n\s*%", "\n##!%", cell) | ||
try: |
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 is a good logic! Can we abstract it out to a method and add tests for that method. It would be amazing if you can do that. Also, we should avoid exception based flow control.
self.shell.set_next_input(formated, replace=True) | ||
except ValueError as e: | ||
formated = cell | ||
print(e) |
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.
Maybe we should have logging.error()
instead of printing the exception.
Solves #5
Fix:
%%black
will be removed even formatting fails.Fix: Ignore all magic calls.