diff --git a/mypy/moduleinspect.py b/mypy/moduleinspect.py index d54746260123..94491de4d804 100644 --- a/mypy/moduleinspect.py +++ b/mypy/moduleinspect.py @@ -45,7 +45,7 @@ def get_package_properties(package_id: str) -> ModuleProperties: package = importlib.import_module(package_id) except BaseException as e: raise InspectError(str(e)) from e - name = getattr(package, '__name__', None) + name = getattr(package, '__name__', package_id) file = getattr(package, '__file__', None) path = getattr(package, '__path__', None) # type: Optional[List[str]] if not isinstance(path, list): diff --git a/mypy/stubdoc.py b/mypy/stubdoc.py index 1baaaecfbdc8..040f44b29cba 100644 --- a/mypy/stubdoc.py +++ b/mypy/stubdoc.py @@ -202,7 +202,7 @@ def args_kwargs(signature: FunctionSig) -> bool: return list(sorted(self.signatures, key=lambda x: 1 if args_kwargs(x) else 0)) -def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[FunctionSig]]: +def infer_sig_from_docstring(docstr: Optional[str], name: str) -> Optional[List[FunctionSig]]: """Convert function signature to list of TypedFunctionSig Look for function signatures of function in docstring. Signature is a string of