Skip to content

Commit 3c125ad

Browse files
authored
Fix error in %edit magic (#1053)
1 parent 6bb9279 commit 3c125ad

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

ipykernel/tests/test_zmq_shell.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,9 @@ def test_magics(tmp_path):
217217
shell.user_ns["hi"] = 1
218218
magics = KernelMagics(shell)
219219

220-
def find_edit_target(*args):
221-
return str(tmp_path), 0, 1
222-
223220
tmp_file = tmp_path / "test.txt"
224221
tmp_file.write_text("hi", "utf8")
225-
magics._find_edit_target = find_edit_target
226-
magics.edit("hi")
222+
magics.edit(str(tmp_file))
227223
magics.clear([])
228224
magics.less(str(tmp_file))
229225
if os.name == "posix":

ipykernel/zmqshell.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ class KernelMagics(Magics):
203203
# the magics which this class needs to implement differently from the base
204204
# class, or that are unique to it.
205205

206-
_find_edit_target = CodeMagics._find_edit_target
207-
208206
@line_magic
209207
def edit(self, parameter_s="", last_call=None):
210208
"""Bring up an editor and execute the resulting code.
@@ -286,7 +284,7 @@ def edit(self, parameter_s="", last_call=None):
286284
opts, args = self.parse_options(parameter_s, "prn:")
287285

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

0 commit comments

Comments
 (0)