##// END OF EJS Templates
Remove many deprecation and bump traitlets to 5+...
Matthias Bussonnier -
Show More
@@ -256,16 +256,6 b' class BaseIPythonApplication(Application):'
256 256 # Various stages of Application creation
257 257 #-------------------------------------------------------------------------
258 258
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
269 259 def init_crash_handler(self):
270 260 """Create a crash handler, typically setting sys.excepthook to it."""
271 261 self.crash_handler = self.crash_handler_class(self)
@@ -144,22 +144,15 b' def BdbQuit_excepthook(et, ev, tb, excepthook=None):'
144 144 All other exceptions are processed using the `excepthook`
145 145 parameter.
146 146 """
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 )
156 150
157 151
158 152 def BdbQuit_IPython_excepthook(self, et, ev, tb, tb_offset=None):
159 warnings.warn(
153 raise ValueError(
160 154 "`BdbQuit_IPython_excepthook` is deprecated since version 5.1",
161 155 DeprecationWarning, stacklevel=2)
162 print('Exiting Debugger.')
163 156
164 157
165 158 RGX_EXTRA_INDENT = re.compile(r'(?<=\n)\s+')
@@ -834,13 +834,11 b' class JSONFormatter(BaseFormatter):'
834 834 if isinstance(r, tuple):
835 835 # unpack data, metadata tuple for type checking on first element
836 836 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
844 842 if md is not None:
845 843 # put the tuple back together
846 844 r = (r, md)
@@ -906,7 +906,11 b' class InteractiveShell(SingletonConfigurable):'
906 906
907 907 if _warn_deprecated and (name in IPython.core.hooks.deprecated):
908 908 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 )
910 914
911 915 if not dp:
912 916 dp = IPython.core.hooks.CommandChainDispatcher()
@@ -933,9 +937,10 b' class InteractiveShell(SingletonConfigurable):'
933 937
934 938 Register a function for calling after code execution.
935 939 """
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 )
939 944
940 945 def _clear_warning_registry(self):
941 946 # clear the warning registry, so that different code blocks with
@@ -98,11 +98,6 b' shell_aliases = dict('
98 98 )
99 99 shell_aliases['cache-size'] = 'InteractiveShell.cache_size'
100 100
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
106 101 #-----------------------------------------------------------------------------
107 102 # Main classes and functions
108 103 #-----------------------------------------------------------------------------
@@ -126,17 +121,6 b' class InteractiveShellApp(Configurable):'
126 121 help="A list of dotted module names of IPython extensions to load."
127 122 ).tag(config=True)
128 123
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
140 124 extra_extensions = List(
141 125 DottedObjectName(),
142 126 help="""
@@ -293,8 +277,6 b' class InteractiveShellApp(Configurable):'
293 277 extensions = (
294 278 self.default_extensions + self.extensions + self.extra_extensions
295 279 )
296 if self.extra_extension:
297 extensions.append(self.extra_extension)
298 280 for ext in extensions:
299 281 try:
300 282 self.log.info("Loading IPython extension: %s" % ext)
@@ -430,18 +430,6 b' def test_ipython_display_formatter():'
430 430 f.ipython_display_formatter.enabled = save_enabled
431 431
432 432
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
445 433 def test_repr_mime():
446 434 class HasReprMime(object):
447 435 def _repr_mimebundle_(self, include=None, exclude=None):
@@ -262,22 +262,6 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
262 262 # internal, not-configurable
263 263 something_to_run=Bool(False)
264 264
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
281 265 @catch_config_error
282 266 def initialize(self, argv=None):
283 267 """Do actions after construct, but before starting the app."""
@@ -67,20 +67,6 b' def get_long_path_name(path):'
67 67 return _get_long_path_name(path)
68 68
69 69
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
84 70 def compress_user(path):
85 71 """Reverse of :func:`os.path.expanduser`
86 72 """
@@ -89,7 +75,7 b' def compress_user(path):'
89 75 path = "~" + path[len(home):]
90 76 return path
91 77
92 def get_py_filename(name, force_win32=None):
78 def get_py_filename(name):
93 79 """Return a valid python filename in the current directory.
94 80
95 81 If the given name is not a file, it adds '.py' and searches again.
@@ -97,10 +83,6 b' def get_py_filename(name, force_win32=None):'
97 83 """
98 84
99 85 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)
104 86 if not os.path.isfile(name) and not name.endswith('.py'):
105 87 name += '.py'
106 88 if os.path.isfile(name):
@@ -253,36 +235,6 b' def get_xdg_cache_dir():'
253 235 return None
254 236
255 237
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
286 238 def expand_path(s):
287 239 """Expand $VARS and ~names in a string, like a shell
288 240
@@ -62,6 +62,7 b' if resource is not None and hasattr(resource, "getrusage"):'
62 62 Similar to clock(), but return a tuple of user/system times."""
63 63 return resource.getrusage(resource.RUSAGE_SELF)[:2]
64 64
65
65 66 else:
66 67 # There is no distinction of user/system time under windows, so we just use
67 68 # time.perff_counter() for everything...
@@ -171,7 +171,6 b' extras_require = dict('
171 171 nbconvert=["nbconvert"],
172 172 )
173 173
174
175 174 everything = set(chain.from_iterable(extras_require.values()))
176 175 extras_require['all'] = list(sorted(everything))
177 176
General Comments 0
You need to be logged in to leave comments. Login now