Skip to content

Commit

Permalink
Fix AttributeError: __args__ on Python 3.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Jun 5, 2021
1 parent 9c81337 commit a5d5ee3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
main
----

* Fix `AttributeError: __args__` when generating stubs on Python 3.9. Thanks
GameDungeon and ntjess for the report. Fixes #231.


21.5.0
------
Expand Down
2 changes: 1 addition & 1 deletion monkeytype/stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_imports_for_annotation(anno: Any) -> ImportMap:
else:
imports[anno.__module__].add(
_get_import_for_qualname(qualname_of_generic(anno)))
elem_types = anno.__args__ or []
elem_types = getattr(anno, "__args__", None) or []
for et in elem_types:
elem_imports = get_imports_for_annotation(et)
imports.merge(elem_imports)
Expand Down

0 comments on commit a5d5ee3

Please sign in to comment.