diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-12 17:24:47 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-12 17:34:45 +0300 |
commit | e84602b8f2b95d10d45eb11369ae7d627339c881 (patch) | |
tree | 028524c9f076a9c4019a8d78d4a30685b7626c99 /contrib/python/ipython/py3/IPython/core/completerlib.py | |
parent | e98c636d759bf6f106a2b90142041bb9d4f1e33f (diff) | |
download | ydb-e84602b8f2b95d10d45eb11369ae7d627339c881.tar.gz |
Intermediate changes
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 a970ba6968..de6c4249b0 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__') |