Skip to content

Commit 0996c42

Browse files
authored
Fix type errors stemming from getattr (#9889)
Fixes #9888. I applied the following patch to typeshed and ran self check: ``` +@overload +def getattr(__o: Any, name: str, __default: None) -> Optional[Any]: ... +@overload def getattr(__o: Any, name: str, __default: Any = ...) -> Any: ... ``` Co-authored-by: hauntsaninja <>
1 parent 5e20a26 commit 0996c42

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mypy/moduleinspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_package_properties(package_id: str) -> ModuleProperties:
4545
package = importlib.import_module(package_id)
4646
except BaseException as e:
4747
raise InspectError(str(e)) from e
48-
name = getattr(package, '__name__', None)
48+
name = getattr(package, '__name__', package_id)
4949
file = getattr(package, '__file__', None)
5050
path = getattr(package, '__path__', None) # type: Optional[List[str]]
5151
if not isinstance(path, list):

mypy/stubdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def args_kwargs(signature: FunctionSig) -> bool:
202202
return list(sorted(self.signatures, key=lambda x: 1 if args_kwargs(x) else 0))
203203

204204

205-
def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[FunctionSig]]:
205+
def infer_sig_from_docstring(docstr: Optional[str], name: str) -> Optional[List[FunctionSig]]:
206206
"""Convert function signature to list of TypedFunctionSig
207207
208208
Look for function signatures of function in docstring. Signature is a string of

0 commit comments

Comments
 (0)