Skip to content

Argument 1 to type_check_only has incompatible type type[S[T, *Ts]]; expected type[S[T, *Ts]] #19093

Open
@jorenham

Description

@jorenham

Consider this .pyi code snippet:

from typing import Any, Generic, Self, TypeVar, TypeVarTuple, type_check_only

T = TypeVar("T")
Ts = TypeVarTuple("Ts") 

@type_check_only
class S(tuple[*Ts], Generic[T, *Ts]):
    def f(self, x: T, /) -> T: ...

When ran through mypy (checked with 1.15.0 and the master branch), the following error is reported

Argument 1 to "type_check_only" has incompatible type "type[S[T, *Ts]]"; expected "type[S[T, *Ts]]"  [arg-type]

mypy playground repro

Without the additional T type parameter, the false positive error disappears. It also disappears if I remove the tuple baseclass.
And as far as I could tell, it doesn't seem to be associated with a particular config option or cli flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions