Skip to content

Conversation

@liurui39660
Copy link

Solves #5
Fix: %%black will be removed even formatting fails.
Fix: Ignore all magic calls.

Rui Liu added 2 commits August 17, 2018 16:13
if cell:
formated = format_str(src_contents=cell, line_length=line_length)
if formated and formated[-1] == "\n":
# Comment magics
Copy link
Owner

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:

  1. Pattern the regex replacing and what it is replacing it with.
  2. Give an example.

# Comment magics
cell = re.sub(r"^%", r"##!%", cell)
cell = re.sub(r"\n\s*%", "\n##!%", cell)
try:
Copy link
Owner

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)
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants