Skip to content
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

noqa on get_ipython #36

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repos:
rev: v0.0.282
hooks:
- id: ruff
exclude: gepetuto/magic.py
args:
- --fix
- --exit-non-zero-on-fix
Expand Down
12 changes: 8 additions & 4 deletions gepetuto/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DoNotLoadMagics(Magics):
def do_not_load_snippet(self, line):
"""Magic command to hide the snippet and let the student code by themself."""
if DoNotLoadMagics.force_load:
get_ipython().run_line_magic("run", "-i " + line)
get_ipython().run_line_magic("load", line) # noqa: F821
self.run("run", "-i " + line)
self.run("load", line)

@line_magic
def force_load(self, line):
Expand All @@ -28,8 +28,12 @@ def force_load(self, line):
@line_magic
def load_snippet(self, line):
"""Magic command to load and run the snippet, this only work on JupyterLab."""
get_ipython().run_line_magic("run", "-i " + line)
get_ipython().run_line_magic("load", line)
self.run("run", "-i " + line)
self.run("load", line)

def run(self, magic, line):
"""Run magic command."""
get_ipython().run_line_magic(magic, line) # noqa: F821


ip = get_ipython() # noqa: F821
Expand Down