🚨 Fix: 错误的类型标注和 annotated 处理 (#2828)

This commit is contained in:
Ju4tCode
2024-07-20 14:03:32 +08:00
committed by GitHub
parent 015ddd9517
commit 2f60c5e9b4
3 changed files with 14 additions and 9 deletions

View File

@ -15,7 +15,7 @@ def combine_driver(driver: type[D]) -> type[D]: ...
@overload
def combine_driver(
driver: type[D], _m: type[Mixin], *mixins: type[Mixin]
driver: type[D], __m: type[Mixin], /, *mixins: type[Mixin]
) -> type["CombinedDriver"]: ...

View File

@ -13,7 +13,6 @@ FrontMatter:
import sys
import types
import warnings
import contextlib
import typing as t
import typing_extensions as t_ext
from typing import TYPE_CHECKING, TypeVar
@ -86,9 +85,7 @@ def all_literal_values(type_: type[t.Any]) -> list[t.Any]:
def origin_is_annotated(origin: t.Optional[type[t.Any]]) -> bool:
"""判断是否是 Annotated 类型"""
with contextlib.suppress(TypeError):
return origin is not None and issubclass(origin, t_ext.Annotated)
return False
return origin is t_ext.Annotated
NONE_TYPES = {None, type(None), t.Literal[None], t_ext.Literal[None]}