Skip to content

Commit

Permalink
remove code deprecated since at least IPython 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Dec 1, 2021
1 parent 341d813 commit 967e96e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ jobs:
env:
COLUMNS: 120
run: |
pytest --color=yes -ra -v --cov --cov-report=xml
pytest --color=yes -raXxs --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
57 changes: 0 additions & 57 deletions IPython/core/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ def no_op(*a, **kw):
class SpaceInInput(Exception): pass


def get_default_colors():
"DEPRECATED"
warn('get_default_color is deprecated since IPython 5.0, and returns `Neutral` on all platforms.',
DeprecationWarning, stacklevel=2)
return 'Neutral'


class SeparateUnicode(Unicode):
r"""A Unicode subclass to validate separate_in, separate_out, etc.
Expand Down Expand Up @@ -440,29 +433,6 @@ def input_splitter(self):
will be displayed as regular output instead."""
).tag(config=True)

# deprecated prompt traits:

prompt_in1 = Unicode('In [\\#]: ',
help="Deprecated since IPython 4.0 and ignored since 5.0, set TerminalInteractiveShell.prompts object directly."
).tag(config=True)
prompt_in2 = Unicode(' .\\D.: ',
help="Deprecated since IPython 4.0 and ignored since 5.0, set TerminalInteractiveShell.prompts object directly."
).tag(config=True)
prompt_out = Unicode('Out[\\#]: ',
help="Deprecated since IPython 4.0 and ignored since 5.0, set TerminalInteractiveShell.prompts object directly."
).tag(config=True)
prompts_pad_left = Bool(True,
help="Deprecated since IPython 4.0 and ignored since 5.0, set TerminalInteractiveShell.prompts object directly."
).tag(config=True)

@observe('prompt_in1', 'prompt_in2', 'prompt_out', 'prompt_pad_left')
def _prompt_trait_changed(self, change):
name = change['name']
warn("InteractiveShell.{name} is deprecated since IPython 4.0"
" and ignored since 5.0, set TerminalInteractiveShell.prompts"
" object directly.".format(name=name))

# protect against weird cases where self.config may not exist:

show_rewritten_input = Bool(True,
help="Show rewritten input, e.g. for autocall."
Expand Down Expand Up @@ -2038,19 +2008,6 @@ def showindentationerror(self):
the %paste magic."""
self.showsyntaxerror()

#-------------------------------------------------------------------------
# Things related to readline
#-------------------------------------------------------------------------

def init_readline(self):
"""DEPRECATED
Moved to terminal subclass, here only to simplify the init logic."""
# Set a number of methods that depend on readline to be no-op
warnings.warn('`init_readline` is no-op since IPython 5.0 and is Deprecated',
DeprecationWarning, stacklevel=2)
self.set_custom_completer = no_op

@skip_doctest
def set_next_input(self, s, replace=False):
""" Sets the 'default' input string for the next command line.
Expand Down Expand Up @@ -3513,20 +3470,6 @@ def mktempfile(self, data=None, prefix='ipython_edit_'):
file_path.write_text(data)
return filename

@undoc
def write(self,data):
"""DEPRECATED: Write a string to the default output"""
warn('InteractiveShell.write() is deprecated, use sys.stdout instead',
DeprecationWarning, stacklevel=2)
sys.stdout.write(data)

@undoc
def write_err(self,data):
"""DEPRECATED: Write a string to the default error output"""
warn('InteractiveShell.write_err() is deprecated, use sys.stderr instead',
DeprecationWarning, stacklevel=2)
sys.stderr.write(data)

def ask_yes_no(self, prompt, default=None, interrupt=None):
if self.quiet:
return True
Expand Down
6 changes: 3 additions & 3 deletions IPython/core/tests/test_magic_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ def test_paste_email_py(self):
def test_paste_echo(self):
"Also test self.paste echoing, by temporarily faking the writer"
w = StringIO()
writer = ip.write
ip.write = w.write
old_write = sys.stdout.write
sys.stdout.write = w.write
code = """
a = 100
b = 200"""
try:
self.paste(code,'')
out = w.getvalue()
finally:
ip.write = writer
sys.stdout.write = old_write
self.assertEqual(ip.user_ns["a"], 100)
self.assertEqual(ip.user_ns["b"], 200)
assert out == code + "\n## -- End pasted text --\n"
Expand Down
9 changes: 4 additions & 5 deletions IPython/terminal/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,10 @@ def paste(self, parameter_s=''):

# By default, echo back to terminal unless quiet mode is requested
if 'q' not in opts:
write = self.shell.write
write(self.shell.pycolorize(block))
if not block.endswith('\n'):
write('\n')
write("## -- End pasted text --\n")
sys.stdout.write(self.shell.pycolorize(block))
if not block.endswith("\n"):
sys.stdout.write("\n")
sys.stdout.write("## -- End pasted text --\n")

self.store_or_execute(block, name)

Expand Down
5 changes: 0 additions & 5 deletions IPython/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ def raw_print_err(*args, **kw):
file=sys.__stderr__)
sys.__stderr__.flush()

# used by IPykernel <- 4.9. Removed during IPython 7-dev period and re-added
# Keep for a version or two then should remove
rprint = raw_print
rprinte = raw_print_err

@undoc
def unicode_std_stream(stream='stdout'):
"""DEPRECATED, moved to nbconvert.utils.io"""
Expand Down

0 comments on commit 967e96e

Please sign in to comment.