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

Fix error in %edit magic #1053

Merged
merged 2 commits into from Dec 8, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions ipykernel/tests/test_zmq_shell.py
Expand Up @@ -217,13 +217,9 @@ def test_magics(tmp_path):
shell.user_ns["hi"] = 1
magics = KernelMagics(shell)

def find_edit_target(*args):
return str(tmp_path), 0, 1

tmp_file = tmp_path / "test.txt"
tmp_file.write_text("hi", "utf8")
magics._find_edit_target = find_edit_target
magics.edit("hi")
magics.edit(str(tmp_file))
magics.clear([])
magics.less(str(tmp_file))
if os.name == "posix":
Expand Down
4 changes: 1 addition & 3 deletions ipykernel/zmqshell.py
Expand Up @@ -203,8 +203,6 @@ class KernelMagics(Magics):
# the magics which this class needs to implement differently from the base
# class, or that are unique to it.

_find_edit_target = CodeMagics._find_edit_target

@line_magic
def edit(self, parameter_s="", last_call=None):
"""Bring up an editor and execute the resulting code.
Expand Down Expand Up @@ -286,7 +284,7 @@ def edit(self, parameter_s="", last_call=None):
opts, args = self.parse_options(parameter_s, "prn:")

try:
filename, lineno, _ = self._find_edit_target(self.shell, args, opts, last_call)
filename, lineno, _ = CodeMagics._find_edit_target(self.shell, args, opts, last_call)
except MacroToEdit:
# TODO: Implement macro editing over 2 processes.
print("Macro editing not yet implemented in 2-process model.")
Expand Down