Skip to content

Commit 807aa2b

Browse files
committed
Fix typing import in Python utils.py
1 parent 26cb345 commit 807aa2b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

generator/plugins/python/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _reset(self):
164164
self._imports: List[str] = [
165165
"import enum",
166166
"import functools",
167-
"from typing import Any, Dict, List, Optional, Tuple, TypeAlias, Union",
167+
"from typing import Any, Dict, List, Optional, Tuple, Union",
168168
"import attrs",
169169
"from . import validators",
170170
]
@@ -576,7 +576,8 @@ def _add_type_alias(self, type_alias: model.TypeAlias) -> None:
576576
if type_alias.type.kind == "reference" and not self._has_type(
577577
type_alias.type.name
578578
):
579-
type_name = f"TypeAlias[{type_name}]"
579+
# TODO: remove workaround for lack of TypeAlias
580+
type_name = f"Union[{type_name}, {type_name}]"
580581

581582
if type_name:
582583
# clean up the docstring for the class itself.
@@ -587,7 +588,7 @@ def _add_type_alias(self, type_alias: model.TypeAlias) -> None:
587588
f"# Since: {_sanitize_comment(type_alias.since)}"
588589
if type_alias.since
589590
else "",
590-
f"# Proposed" if type_alias.proposed else "",
591+
"# Proposed" if type_alias.proposed else "",
591592
]
592593
else:
593594
doc = _get_indented_documentation(type_alias.documentation, indent)

0 commit comments

Comments
 (0)