Skip to content

Commit

Permalink
Fix crash on completion for optional six modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed May 14, 2024
1 parent 1066e43 commit 448682b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions IPython/core/completerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ def get_root_modules():
return rootmodules


def is_importable(module, attr, only_modules):
def is_importable(module, attr:str, only_modules) -> bool:
if only_modules:
return inspect.ismodule(getattr(module, attr))
try:
mod = getattr(module, attr)
except ModuleNotFoundError:
# See gh-14434
return False
return inspect.ismodule(mod)
else:
return not(attr[:2] == '__' and attr[-2:] == '__')

Expand Down

0 comments on commit 448682b

Please sign in to comment.