Skip to content

Commit

Permalink
use getattr for < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Jul 21, 2024
1 parent 70e4928 commit d2d2d76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def generate_class_stub(self, class_name: str, cls: type, output: list[str]) ->
if sys.version_info >= (3, 10):
annotations = inspect.get_annotations(cls)
else:
annotations = cls.__annotations__
annotations = getattr(cls, '__annotations__', {})

for attr, value in attrs:
if attr == "__hash__" and value is None:
Expand Down Expand Up @@ -914,7 +914,7 @@ def generate_variable_stub(self, name: str, obj: object, output: list[str]) -> N
if sys.version_info >= (3, 10):
annotations = inspect.get_annotations(self.module)
else:
annotations = self.module.__annotations__
annotations = getattr(self.module, '__annotations__', {})

if name in annotations:
type_str = self.strip_or_import(annotations[name])
Expand Down

0 comments on commit d2d2d76

Please sign in to comment.