MCPcopy Index your code
hub / github.com/ipython/ipython / can_import

Function can_import

IPython/external/qt_loaders.py:182–191  ·  view source on GitHub ↗

Safely query whether an API is importable, without importing it

(api)

Source from the content-addressed store, hash-verified

180
181
182def can_import(api):
183 """Safely query whether an API is importable, without importing it"""
184 if not has_binding(api):
185 return False
186
187 current = loaded_api()
188 if api == QT_API_PYQT_DEFAULT:
189 return current in [QT_API_PYQT6, None]
190 else:
191 return current in [api, None]
192
193
194def import_pyqt4(version=2):

Callers 1

load_qtFunction · 0.85

Calls 2

has_bindingFunction · 0.85
loaded_apiFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…