summaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/external
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
committerrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
commit9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch)
tree78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/external
parent8113a823ffca6451bb5ff8f0334560885a939a24 (diff)
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/external')
-rw-r--r--contrib/python/ipython/py3/IPython/external/__init__.py4
-rw-r--r--contrib/python/ipython/py3/IPython/external/decorators/__init__.py8
-rw-r--r--contrib/python/ipython/py3/IPython/external/decorators/_decorators.py143
-rw-r--r--contrib/python/ipython/py3/IPython/external/decorators/_numpy_testing_noseclasses.py41
-rw-r--r--contrib/python/ipython/py3/IPython/external/mathjax.py13
-rw-r--r--contrib/python/ipython/py3/IPython/external/qt_for_kernel.py5
-rw-r--r--contrib/python/ipython/py3/IPython/external/qt_loaders.py54
7 files changed, 31 insertions, 237 deletions
diff --git a/contrib/python/ipython/py3/IPython/external/__init__.py b/contrib/python/ipython/py3/IPython/external/__init__.py
index 1c8c546f118..eedc338eb84 100644
--- a/contrib/python/ipython/py3/IPython/external/__init__.py
+++ b/contrib/python/ipython/py3/IPython/external/__init__.py
@@ -2,4 +2,6 @@
This package contains all third-party modules bundled with IPython.
"""
-__all__ = []
+from typing import List
+
+__all__: List[str] = []
diff --git a/contrib/python/ipython/py3/IPython/external/decorators/__init__.py b/contrib/python/ipython/py3/IPython/external/decorators/__init__.py
deleted file mode 100644
index 1db80edd357..00000000000
--- a/contrib/python/ipython/py3/IPython/external/decorators/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-try:
- from numpy.testing import KnownFailure, knownfailureif
-except ImportError:
- from ._decorators import knownfailureif
- try:
- from ._numpy_testing_noseclasses import KnownFailure
- except ImportError:
- pass
diff --git a/contrib/python/ipython/py3/IPython/external/decorators/_decorators.py b/contrib/python/ipython/py3/IPython/external/decorators/_decorators.py
deleted file mode 100644
index 18f847adadd..00000000000
--- a/contrib/python/ipython/py3/IPython/external/decorators/_decorators.py
+++ /dev/null
@@ -1,143 +0,0 @@
-"""
-Decorators for labeling and modifying behavior of test objects.
-
-Decorators that merely return a modified version of the original
-function object are straightforward. Decorators that return a new
-function object need to use
-::
-
- nose.tools.make_decorator(original_function)(decorator)
-
-in returning the decorator, in order to preserve meta-data such as
-function name, setup and teardown functions and so on - see
-``nose.tools`` for more information.
-
-"""
-
-# IPython changes: make this work if numpy not available
-# Original code:
-try:
- from ._numpy_testing_noseclasses import KnownFailureTest
-except:
- pass
-
-# End IPython changes
-
-
-def skipif(skip_condition, msg=None):
- """
- Make function raise SkipTest exception if a given condition is true.
-
- If the condition is a callable, it is used at runtime to dynamically
- make the decision. This is useful for tests that may require costly
- imports, to delay the cost until the test suite is actually executed.
-
- Parameters
- ----------
- skip_condition : bool or callable
- Flag to determine whether to skip the decorated test.
- msg : str, optional
- Message to give on raising a SkipTest exception. Default is None.
-
- Returns
- -------
- decorator : function
- Decorator which, when applied to a function, causes SkipTest
- to be raised when `skip_condition` is True, and the function
- to be called normally otherwise.
-
- Notes
- -----
- The decorator itself is decorated with the ``nose.tools.make_decorator``
- function in order to transmit function name, and various other metadata.
-
- """
-
- def skip_decorator(f):
- # Local import to avoid a hard nose dependency and only incur the
- # import time overhead at actual test-time.
- import nose
-
- # Allow for both boolean or callable skip conditions.
- if callable(skip_condition):
- skip_val = lambda : skip_condition()
- else:
- skip_val = lambda : skip_condition
-
- def get_msg(func,msg=None):
- """Skip message with information about function being skipped."""
- if msg is None:
- out = 'Test skipped due to test condition'
- else:
- out = '\n'+msg
-
- return "Skipping test: %s%s" % (func.__name__,out)
-
- # We need to define *two* skippers because Python doesn't allow both
- # return with value and yield inside the same function.
- def skipper_func(*args, **kwargs):
- """Skipper for normal test functions."""
- if skip_val():
- raise nose.SkipTest(get_msg(f,msg))
- else:
- return f(*args, **kwargs)
-
- def skipper_gen(*args, **kwargs):
- """Skipper for test generators."""
- if skip_val():
- raise nose.SkipTest(get_msg(f,msg))
- else:
- for x in f(*args, **kwargs):
- yield x
-
- # Choose the right skipper to use when building the actual decorator.
- if nose.util.isgenerator(f):
- skipper = skipper_gen
- else:
- skipper = skipper_func
-
- return nose.tools.make_decorator(f)(skipper)
-
- return skip_decorator
-
-def knownfailureif(fail_condition, msg=None):
- """
- Make function raise KnownFailureTest exception if given condition is true.
-
- Parameters
- ----------
- fail_condition : bool
- Flag to determine whether to mark the decorated test as a known
- failure (if True) or not (if False).
- msg : str, optional
- Message to give on raising a KnownFailureTest exception.
- Default is None.
-
- Returns
- -------
- decorator : function
- Decorator, which, when applied to a function, causes KnownFailureTest to
- be raised when `fail_condition` is True and the test fails.
-
- Notes
- -----
- The decorator itself is decorated with the ``nose.tools.make_decorator``
- function in order to transmit function name, and various other metadata.
-
- """
- if msg is None:
- msg = 'Test skipped due to known failure'
-
- def knownfail_decorator(f):
- # Local import to avoid a hard nose dependency and only incur the
- # import time overhead at actual test-time.
- import nose
-
- def knownfailer(*args, **kwargs):
- if fail_condition:
- raise KnownFailureTest(msg)
- else:
- return f(*args, **kwargs)
- return nose.tools.make_decorator(f)(knownfailer)
-
- return knownfail_decorator
diff --git a/contrib/python/ipython/py3/IPython/external/decorators/_numpy_testing_noseclasses.py b/contrib/python/ipython/py3/IPython/external/decorators/_numpy_testing_noseclasses.py
deleted file mode 100644
index ca6ccd87bbc..00000000000
--- a/contrib/python/ipython/py3/IPython/external/decorators/_numpy_testing_noseclasses.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# IPython: modified copy of numpy.testing.noseclasses, so
-# IPython.external._decorators works without numpy being installed.
-
-# These classes implement a "known failure" error class.
-
-import os
-
-from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
-
-class KnownFailureTest(Exception):
- '''Raise this exception to mark a test as a known failing test.'''
- pass
-
-
-class KnownFailure(ErrorClassPlugin):
- '''Plugin that installs a KNOWNFAIL error class for the
- KnownFailureClass exception. When KnownFailureTest is raised,
- the exception will be logged in the knownfail attribute of the
- result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the
- exception will not be counted as an error or failure.'''
- enabled = True
- knownfail = ErrorClass(KnownFailureTest,
- label='KNOWNFAIL',
- isfailure=False)
-
- def options(self, parser, env=os.environ):
- env_opt = 'NOSE_WITHOUT_KNOWNFAIL'
- parser.add_option('--no-knownfail', action='store_true',
- dest='noKnownFail', default=env.get(env_opt, False),
- help='Disable special handling of KnownFailureTest '
- 'exceptions')
-
- def configure(self, options, conf):
- if not self.can_configure:
- return
- self.conf = conf
- disable = getattr(options, 'noKnownFail', False)
- if disable:
- self.enabled = False
-
-
diff --git a/contrib/python/ipython/py3/IPython/external/mathjax.py b/contrib/python/ipython/py3/IPython/external/mathjax.py
deleted file mode 100644
index 1b9b80905ba..00000000000
--- a/contrib/python/ipython/py3/IPython/external/mathjax.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-"""
-`IPython.external.mathjax` is deprecated with IPython 4.0+
-
-mathjax is now install by default with the notebook package
-
-"""
-
-import sys
-
-if __name__ == '__main__' :
- sys.exit("IPython.external.mathjax is deprecated, Mathjax is now installed by default with the notebook package")
-
diff --git a/contrib/python/ipython/py3/IPython/external/qt_for_kernel.py b/contrib/python/ipython/py3/IPython/external/qt_for_kernel.py
index d2e7bd99f01..b3168f6e2e0 100644
--- a/contrib/python/ipython/py3/IPython/external/qt_for_kernel.py
+++ b/contrib/python/ipython/py3/IPython/external/qt_for_kernel.py
@@ -31,7 +31,6 @@ else:
import os
import sys
-from IPython.utils.version import check_version
from IPython.external.qt_loaders import (
load_qt,
loaded_api,
@@ -101,8 +100,8 @@ def get_options():
mpl = sys.modules.get('matplotlib', None)
- if mpl is not None and not check_version(mpl.__version__, '1.0.2'):
- #1.0.1 only supports PyQt4 v1
+ if mpl is not None and tuple(mpl.__version__.split(".")) < ("1", "0", "2"):
+ # 1.0.1 only supports PyQt4 v1
return [QT_API_PYQT_DEFAULT]
qt_api = os.environ.get('QT_API', None)
diff --git a/contrib/python/ipython/py3/IPython/external/qt_loaders.py b/contrib/python/ipython/py3/IPython/external/qt_loaders.py
index 79805358e72..39ea298460b 100644
--- a/contrib/python/ipython/py3/IPython/external/qt_loaders.py
+++ b/contrib/python/ipython/py3/IPython/external/qt_loaders.py
@@ -8,13 +8,12 @@ bindings, which is unstable and likely to crash
This is used primarily by qt and qt_for_kernel, and shouldn't
be accessed directly from the outside
"""
+import importlib.abc
import sys
import types
from functools import partial, lru_cache
import operator
-from IPython.utils.version import check_version
-
# ### Available APIs.
# Qt6
QT_API_PYQT6 = "pyqt6"
@@ -47,7 +46,7 @@ api_to_module = {
}
-class ImportDenier(object):
+class ImportDenier(importlib.abc.MetaPathFinder):
"""Import Hook that will guard against bad Qt imports
once IPython commits to a specific binding
"""
@@ -59,17 +58,17 @@ class ImportDenier(object):
sys.modules.pop(module_name, None)
self.__forbidden.add(module_name)
- def find_module(self, fullname, path=None):
+ def find_spec(self, fullname, path, target=None):
if path:
return
if fullname in self.__forbidden:
- return self
-
- def load_module(self, fullname):
- raise ImportError("""
+ raise ImportError(
+ """
Importing %s disabled by IPython, which has
already imported an Incompatible QT Binding: %s
- """ % (fullname, loaded_api()))
+ """
+ % (fullname, loaded_api())
+ )
ID = ImportDenier()
@@ -78,7 +77,7 @@ sys.meta_path.insert(0, ID)
def commit_api(api):
"""Commit to a particular API, and trigger ImportErrors on subsequent
- dangerous imports"""
+ dangerous imports"""
modules = set(api_to_module.values())
modules.remove(api_to_module[api])
@@ -118,15 +117,15 @@ def loaded_api():
def has_binding(api):
"""Safely check for PyQt4/5, PySide or PySide2, without importing submodules
- Parameters
- ----------
- api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
- Which module to check for
+ Parameters
+ ----------
+ api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
+ Which module to check for
- Returns
- -------
- True if the relevant module appears to be importable
- """
+ Returns
+ -------
+ True if the relevant module appears to be importable
+ """
module_name = api_to_module[api]
from importlib.util import find_spec
@@ -149,7 +148,8 @@ def has_binding(api):
if api == QT_API_PYSIDE:
# We can also safely check PySide version
import PySide
- return check_version(PySide.__version__, '1.0.3')
+
+ return PySide.__version_info__ >= (1, 0, 3)
return True
@@ -195,10 +195,9 @@ def import_pyqt4(version=2):
Parameters
----------
version : 1, 2, or None
- Which QString/QVariant API to use. Set to None to use the system
- default
-
- ImportErrors rasied within this function are non-recoverable
+ Which QString/QVariant API to use. Set to None to use the system
+ default
+ ImportErrors raised within this function are non-recoverable
"""
# The new-style string API (version=2) automatically
# converts QStrings to Unicode Python strings. Also, automatically unpacks
@@ -211,7 +210,7 @@ def import_pyqt4(version=2):
from PyQt4 import QtGui, QtCore, QtSvg
- if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
+ if QtCore.PYQT_VERSION < 0x040700:
raise ImportError("IPython requires PyQt4 >= 4.7, found %s" %
QtCore.PYQT_VERSION_STR)
@@ -229,7 +228,7 @@ def import_pyqt5():
"""
Import PyQt5
- ImportErrors rasied within this function are non-recoverable
+ ImportErrors raised within this function are non-recoverable
"""
from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui
@@ -251,7 +250,7 @@ def import_pyqt6():
"""
Import PyQt6
- ImportErrors rasied within this function are non-recoverable
+ ImportErrors raised within this function are non-recoverable
"""
from PyQt6 import QtCore, QtSvg, QtWidgets, QtGui
@@ -321,13 +320,12 @@ def load_qt(api_options):
Parameters
----------
- api_options: List of strings
+ api_options : List of strings
The order of APIs to try. Valid items are 'pyside', 'pyside2',
'pyqt', 'pyqt5', 'pyqtv1' and 'pyqtdefault'
Returns
-------
-
A tuple of QtCore, QtGui, QtSvg, QT_API
The first three are the Qt modules. The last is the
string indicating which module was loaded.