From e54372ee6367f5d10158bdd0816c9585fe816f82 2022-02-08 12:00:37 From: Matthias Bussonnier Date: 2022-02-08 12:00:37 Subject: [PATCH] Merge pull request #13518 from Carreau/maint-deprecate-append-to-sys Maint deprecate append to sys --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index ccb1f46..9774fd5 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -2222,12 +2222,22 @@ class IPCompleter(Completer): # initialized, and it takes a user-noticeable amount of time to # initialize it, so we don't want to initialize it unless we're # actually going to use it. - s = text[slashpos+1:] - candidates = [x for x in self.unicode_names if x.startswith(s)] + s = text[slashpos + 1 :] + sup = s.upper() + candidates = [x for x in self.unicode_names if x.startswith(sup)] if candidates: return s, candidates - else: - return '', () + candidates = [x for x in self.unicode_names if sup in x] + if candidates: + return s, candidates + splitsup = sup.split(" ") + candidates = [ + x for x in self.unicode_names if all(u in x for u in splitsup) + ] + if candidates: + return s, candidates + + return "", () # if text does not start with slash else: diff --git a/IPython/utils/syspathcontext.py b/IPython/utils/syspathcontext.py index bd1c515..7af1ab6 100644 --- a/IPython/utils/syspathcontext.py +++ b/IPython/utils/syspathcontext.py @@ -15,12 +15,21 @@ Authors: #----------------------------------------------------------------------------- import sys +import warnings class appended_to_syspath(object): - """A context for appending a directory to sys.path for a second.""" + """ + Deprecated since IPython 8.1, no replacements. + + A context for appending a directory to sys.path for a second.""" def __init__(self, dir): + warnings.warn( + "`appended_to_syspath` is deprecated since IPython 8.1, and has no replacements", + DeprecationWarning, + stacklevel=2, + ) self.dir = dir def __enter__(self): diff --git a/IPython/utils/tests/test_deprecated.py b/IPython/utils/tests/test_deprecated.py new file mode 100644 index 0000000..f6f54ce --- /dev/null +++ b/IPython/utils/tests/test_deprecated.py @@ -0,0 +1,7 @@ +from IPython.utils.syspathcontext import appended_to_syspath +import pytest + + +def test_append_deprecated(): + with pytest.warns(DeprecationWarning): + appended_to_syspath(".") diff --git a/IPython/utils/version.py b/IPython/utils/version.py index 0501556..8c65c78 100644 --- a/IPython/utils/version.py +++ b/IPython/utils/version.py @@ -14,7 +14,10 @@ It is a bit ridiculous that we need these. from warnings import warn -warn("The `IPython.utils.version` module has been deprecated since IPython 8.0.") +warn( + "The `IPython.utils.version` module has been deprecated since IPython 8.0.", + DeprecationWarning, +) def check_version(v, check):