Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63cb21b

Browse files
authored
Merge pull request #13381 from Carreau/more-deprecations
Remove many deprecation and bump traitlets to 5+
2 parents 833cf4c + fc5ec10 commit 63cb21b

12 files changed

Lines changed: 23 additions & 136 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ on:
1010
branches: [ master, 7.x ]
1111

1212
jobs:
13-
build:
13+
formatting:
1414

1515
runs-on: ubuntu-latest
16-
timeout-minutes: 10
16+
timeout-minutes: 5
1717
strategy:
1818
matrix:
1919
python-version: [3.8]
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip
32-
pip install darker isort
32+
pip install darker
3333
- name: Lint with darker
3434
run: |
3535
darker -r 60625f241f298b5039cb2debc365db38aa7bb522 --check --diff . || (

IPython/core/application.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ def __init__(self, **kwargs):
256256
# Various stages of Application creation
257257
#-------------------------------------------------------------------------
258258

259-
deprecated_subcommands = {}
260-
261-
def initialize_subcommand(self, subc, argv=None):
262-
if subc in self.deprecated_subcommands:
263-
self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed "
264-
"in future versions.".format(sub=subc))
265-
self.log.warning("You likely want to use `jupyter {sub}` in the "
266-
"future".format(sub=subc))
267-
return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv)
268-
269259
def init_crash_handler(self):
270260
"""Create a crash handler, typically setting sys.excepthook to it."""
271261
self.crash_handler = self.crash_handler_class(self)

IPython/core/debugger.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,15 @@ def BdbQuit_excepthook(et, ev, tb, excepthook=None):
144144
All other exceptions are processed using the `excepthook`
145145
parameter.
146146
"""
147-
warnings.warn("`BdbQuit_excepthook` is deprecated since version 5.1",
148-
DeprecationWarning, stacklevel=2)
149-
if et == bdb.BdbQuit:
150-
print('Exiting Debugger.')
151-
elif excepthook is not None:
152-
excepthook(et, ev, tb)
153-
else:
154-
# Backwards compatibility. Raise deprecation warning?
155-
BdbQuit_excepthook.excepthook_ori(et, ev, tb)
147+
raise ValueError(
148+
"`BdbQuit_excepthook` is deprecated since version 5.1",
149+
)
156150

157151

158152
def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None):
159-
warnings.warn(
153+
raise ValueError(
160154
"`BdbQuit_IPython_excepthook` is deprecated since version 5.1",
161155
DeprecationWarning, stacklevel=2)
162-
print('Exiting Debugger.')
163156

164157

165158
RGX_EXTRA_INDENT = re.compile(r'(?<=\n)\s+')

IPython/core/formatters.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,13 +834,11 @@ def _check_return(self, r, obj):
834834
if isinstance(r, tuple):
835835
# unpack data, metadata tuple for type checking on first element
836836
r, md = r
837-
838-
# handle deprecated JSON-as-string form from IPython < 3
839-
if isinstance(r, str):
840-
warnings.warn("JSON expects JSONable list/dict containers, not JSON strings",
841-
FormatterWarning)
842-
r = json.loads(r)
843-
837+
838+
assert not isinstance(
839+
r, str
840+
), "JSON-as-string has been deprecated since IPython < 3"
841+
844842
if md is not None:
845843
# put the tuple back together
846844
r = (r, md)

IPython/core/interactiveshell.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,11 @@ def set_hook(self,name,hook, priority=50, str_key=None, re_key=None,
906906

907907
if _warn_deprecated and (name in IPython.core.hooks.deprecated):
908908
alternative = IPython.core.hooks.deprecated[name]
909-
warn("Hook {} is deprecated. Use {} instead.".format(name, alternative), stacklevel=2)
909+
raise ValueError(
910+
"Hook {} has been deprecated since IPython 5.0. Use {} instead.".format(
911+
name, alternative
912+
)
913+
)
910914

911915
if not dp:
912916
dp = IPython.core.hooks.CommandChainDispatcher()
@@ -933,9 +937,10 @@ def register_post_execute(self, func):
933937
934938
Register a function for calling after code execution.
935939
"""
936-
warn("ip.register_post_execute is deprecated, use "
937-
"ip.events.register('post_run_cell', func) instead.", stacklevel=2)
938-
self.events.register('post_run_cell', func)
940+
raise ValueError(
941+
"ip.register_post_execute is deprecated since IPython 1.0, use "
942+
"ip.events.register('post_run_cell', func) instead."
943+
)
939944

940945
def _clear_warning_registry(self):
941946
# clear the warning registry, so that different code blocks with

IPython/core/shellapp.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@
9898
)
9999
shell_aliases['cache-size'] = 'InteractiveShell.cache_size'
100100

101-
if traitlets.version_info < (5, 0):
102-
# traitlets 4 doesn't handle lists on CLI
103-
shell_aliases["ext"] = "InteractiveShellApp.extra_extension"
104-
105-
106101
#-----------------------------------------------------------------------------
107102
# Main classes and functions
108103
#-----------------------------------------------------------------------------
@@ -126,17 +121,6 @@ class InteractiveShellApp(Configurable):
126121
help="A list of dotted module names of IPython extensions to load."
127122
).tag(config=True)
128123

129-
extra_extension = Unicode(
130-
"",
131-
help="""
132-
DEPRECATED. Dotted module name of a single extra IPython extension to load.
133-
134-
Only one extension can be added this way.
135-
136-
Only used with traitlets < 5.0, plural extra_extensions list is used in traitlets 5.
137-
""",
138-
).tag(config=True)
139-
140124
extra_extensions = List(
141125
DottedObjectName(),
142126
help="""
@@ -293,8 +277,6 @@ def init_extensions(self):
293277
extensions = (
294278
self.default_extensions + self.extensions + self.extra_extensions
295279
)
296-
if self.extra_extension:
297-
extensions.append(self.extra_extension)
298280
for ext in extensions:
299281
try:
300282
self.log.info("Loading IPython extension: %s" % ext)

IPython/core/tests/test_formatters.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,6 @@ def _ipython_display_(self):
430430
f.ipython_display_formatter.enabled = save_enabled
431431

432432

433-
def test_json_as_string_deprecated():
434-
class JSONString(object):
435-
def _repr_json_(self):
436-
return '{}'
437-
438-
f = JSONFormatter()
439-
with warnings.catch_warnings(record=True) as w:
440-
d = f(JSONString())
441-
assert d == {}
442-
assert len(w) == 1
443-
444-
445433
def test_repr_mime():
446434
class HasReprMime(object):
447435
def _repr_mimebundle_(self, include=None, exclude=None):

IPython/terminal/ipapp.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,6 @@ def _file_to_run_changed(self, change):
262262
# internal, not-configurable
263263
something_to_run=Bool(False)
264264

265-
def parse_command_line(self, argv=None):
266-
"""override to allow old '-pylab' flag with deprecation warning"""
267-
268-
argv = sys.argv[1:] if argv is None else argv
269-
270-
if '-pylab' in argv:
271-
# deprecated `-pylab` given,
272-
# warn and transform into current syntax
273-
argv = argv[:] # copy, don't clobber
274-
idx = argv.index('-pylab')
275-
warnings.warn("`-pylab` flag has been deprecated.\n"
276-
" Use `--matplotlib <backend>` and import pylab manually.")
277-
argv[idx] = '--pylab'
278-
279-
return super(TerminalIPythonApp, self).parse_command_line(argv)
280-
281265
@catch_config_error
282266
def initialize(self, argv=None):
283267
"""Do actions after construct, but before starting the app."""

IPython/testing/decorators.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ def module_not_available(module):
152152
"This test only runs under Windows")
153153
skip_if_not_linux = skipif(not sys.platform.startswith('linux'),
154154
"This test only runs under Linux")
155-
skip_if_not_osx = skipif(sys.platform != 'darwin',
156-
"This test only runs under OSX")
157-
158155

159156
_x11_skip_cond = (sys.platform not in ('darwin', 'win32') and
160157
os.environ.get('DISPLAY', '') == '')
@@ -171,8 +168,6 @@ def module_not_available(module):
171168

172169
skipif_not_matplotlib = skip_without('matplotlib')
173170

174-
skipif_not_sympy = skip_without('sympy')
175-
176171
# A null 'decorator', useful to make more readable code that needs to pick
177172
# between different decorators based on OS or other conditions
178173
null_deco = lambda f: f

IPython/utils/path.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,6 @@ def get_long_path_name(path):
6767
return _get_long_path_name(path)
6868

6969

70-
def unquote_filename(name, win32=(sys.platform=='win32')):
71-
""" On Windows, remove leading and trailing quotes from filenames.
72-
73-
This function has been deprecated and should not be used any more:
74-
unquoting is now taken care of by :func:`IPython.utils.process.arg_split`.
75-
"""
76-
warn("'unquote_filename' is deprecated since IPython 5.0 and should not "
77-
"be used anymore", DeprecationWarning, stacklevel=2)
78-
if win32:
79-
if name.startswith(("'", '"')) and name.endswith(("'", '"')):
80-
name = name[1:-1]
81-
return name
82-
83-
8470
def compress_user(path):
8571
"""Reverse of :func:`os.path.expanduser`
8672
"""
@@ -89,18 +75,14 @@ def compress_user(path):
8975
path = "~" + path[len(home):]
9076
return path
9177

92-
def get_py_filename(name, force_win32=None):
78+
def get_py_filename(name):
9379
"""Return a valid python filename in the current directory.
9480
9581
If the given name is not a file, it adds '.py' and searches again.
9682
Raises IOError with an informative message if the file isn't found.
9783
"""
9884

9985
name = os.path.expanduser(name)
100-
if force_win32 is not None:
101-
warn("The 'force_win32' argument to 'get_py_filename' is deprecated "
102-
"since IPython 5.0 and should not be used anymore",
103-
DeprecationWarning, stacklevel=2)
10486
if not os.path.isfile(name) and not name.endswith('.py'):
10587
name += '.py'
10688
if os.path.isfile(name):
@@ -253,36 +235,6 @@ def get_xdg_cache_dir():
253235
return None
254236

255237

256-
@undoc
257-
def get_ipython_dir():
258-
warn("get_ipython_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
259-
from IPython.paths import get_ipython_dir
260-
return get_ipython_dir()
261-
262-
@undoc
263-
def get_ipython_cache_dir():
264-
warn("get_ipython_cache_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
265-
from IPython.paths import get_ipython_cache_dir
266-
return get_ipython_cache_dir()
267-
268-
@undoc
269-
def get_ipython_package_dir():
270-
warn("get_ipython_package_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
271-
from IPython.paths import get_ipython_package_dir
272-
return get_ipython_package_dir()
273-
274-
@undoc
275-
def get_ipython_module_path(module_str):
276-
warn("get_ipython_module_path has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
277-
from IPython.paths import get_ipython_module_path
278-
return get_ipython_module_path(module_str)
279-
280-
@undoc
281-
def locate_profile(profile='default'):
282-
warn("locate_profile has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
283-
from IPython.paths import locate_profile
284-
return locate_profile(profile=profile)
285-
286238
def expand_path(s):
287239
"""Expand $VARS and ~names in a string, like a shell
288240

0 commit comments

Comments
 (0)