Skip to content

Commit

Permalink
Fix error in %edit magic (#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored Dec 8, 2022
1 parent 6bb9279 commit 3c125ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 1 addition & 5 deletions ipykernel/tests/test_zmq_shell.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 3c125ad

Please sign in to comment.