diff options
| author | Alexander Smirnov <[email protected]> | 2024-03-13 10:33:47 +0000 |
|---|---|---|
| committer | Alexander Smirnov <[email protected]> | 2024-03-13 10:33:47 +0000 |
| commit | 1df54be5538361db7f33afc618d1597272414294 (patch) | |
| tree | bb39e4b75db0b0a9722468eacef91ffd1388eb8d /contrib/python/ipython/py3/IPython/core/completerlib.py | |
| parent | 7a673cf01feefbe95bf5e7396d9179a5f283aeba (diff) | |
| parent | 01aef806626b16e9817e07f718f10e151f52e400 (diff) | |
Merge branch 'rightlib' into mergelibs-240313-1032
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/completerlib.py')
| -rw-r--r-- | contrib/python/ipython/py3/IPython/core/completerlib.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/completerlib.py b/contrib/python/ipython/py3/IPython/core/completerlib.py index a970ba69680..de6c4249b01 100644 --- a/contrib/python/ipython/py3/IPython/core/completerlib.py +++ b/contrib/python/ipython/py3/IPython/core/completerlib.py @@ -67,6 +67,7 @@ magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$') # Local utilities #----------------------------------------------------------------------------- + arcadia_rootmodules_cache = None arcadia_modules_cache = None @@ -111,7 +112,7 @@ def arcadia_get_root_modules(): return arcadia_rootmodules_cache -def module_list(path): +def module_list(path: str) -> List[str]: """ Return the list containing the names of the modules available in the given folder. @@ -127,7 +128,7 @@ def module_list(path): # Build a list of all files in the directory and all files # in its subdirectories. For performance reasons, do not # recurse more than one level into subdirectories. - files = [] + files: List[str] = [] for root, dirs, nondirs in os.walk(path, followlinks=True): subdir = root[len(path)+1:] if subdir: @@ -138,8 +139,8 @@ def module_list(path): else: try: - files = list(zipimporter(path)._files.keys()) - except: + files = list(zipimporter(path)._files.keys()) # type: ignore + except Exception: files = [] # Build a list of modules which match the import_re regex. @@ -242,6 +243,9 @@ def try_import(mod: str, only_modules=False) -> List[str]: if m_is_init: file_ = m.__file__ + file_path = os.path.dirname(file_) # type: ignore + if file_path is not None: + completions.extend(module_list(file_path)) completions.extend(arcadia_module_list(mod)) completions_set = {c for c in completions if isinstance(c, str)} completions_set.discard('__init__') |
