Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type errors stemming from getattr #9889

Merged
merged 4 commits into from Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/moduleinspect.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypy/stubdoc.py
Expand Up @@ -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
Expand Down