Feature: 支持 PEP 695 类型别名 (#3621)

This commit is contained in:
Ju4tCode
2025-08-07 14:54:22 +08:00
committed by GitHub
parent 56f52f2c9f
commit 0d8b81614a
16 changed files with 232 additions and 9 deletions

View File

@ -99,6 +99,17 @@ def is_none_type(type_: type[t.Any]) -> bool:
return type_ in NONE_TYPES
if sys.version_info < (3, 12):
def is_type_alias_type(type_: type[t.Any]) -> bool:
"""判断是否是 TypeAliasType 类型"""
return isinstance(type_, t_ext.TypeAliasType)
else:
def is_type_alias_type(type_: type[t.Any]) -> bool:
return isinstance(type_, (t.TypeAliasType, t_ext.TypeAliasType))
def evaluate_forwardref(
ref: t.ForwardRef, globalns: dict[str, t.Any], localns: dict[str, t.Any]
) -> t.Any: