Consider:
fromdataclassesimportis_dataclassdeff(X: type) ->None:
ifis_dataclass(X):
reveal_type(X) # information: Type of "X" is "type"
Ideally, X would have type type[DataclassInstance]. It doesn't because is_dataclass is defined:
@overloaddefis_dataclass(obj: DataclassInstance|type[DataclassInstance]) ->Literal[True]: ...
@overloaddefis_dataclass(obj: type) ->TypeGuard[type[DataclassInstance]]: ...
@overloaddefis_dataclass(obj: object) ->TypeGuard[DataclassInstance|type[DataclassInstance]]: ...
And the argument of type type matches the first overload, which does not incorporate a TypeGuard. Eric Traut recommends erasing the first overload of is_dataclass.
Consider:
Ideally,
Xwould have typetype[DataclassInstance]. It doesn't becauseis_dataclassis defined:And the argument of type
typematches the first overload, which does not incorporate aTypeGuard. Eric Traut recommends erasing the first overload ofis_dataclass.