Skip to content

Ignore all magics#6

Open
liurui39660 wants to merge 2 commits intocsurfer:masterfrom
liurui39660:master
Open

Ignore all magics#6
liurui39660 wants to merge 2 commits intocsurfer:masterfrom
liurui39660:master

Conversation

@liurui39660
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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