Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type arguments of type aliases aren't checked against their definitions, only the underlying type #969

Open
KotlinIsland opened this issue Dec 27, 2024 · 1 comment
Labels
type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules upstream bug a bug that also exists in pyright but has not been raised upstream

Comments

@KotlinIsland
Copy link
Collaborator

class A[T: (int, str)]: ...

type BoolA[T: bool] = A[T]
BoolA[str]
BoolA[bool]

type B[T: str] = object
type C[T: int] = B[T]  # error

C[str]
B[int]
@KotlinIsland KotlinIsland added type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules upstream bug a bug that also exists in pyright but has not been raised upstream labels Dec 27, 2024
@DetachHead
Copy link
Owner

looks like this only happens when enableExperimentalFeatures is disabled and the type alias is used as a value instead of an annotation.

Code sample in basedpyright playground

class A[T: (int, str)]: ...

type BoolA[T: bool] = A[T] # no error (false negative), didn't we already have a separate issue for this?
BoolA[str] # no error (false negative)
BoolA[bool] # no error (correct)

type B[T: str] = object
type C[T: int] = B[T]  # error (correct)

C[str] # no error (false negative)
B[int] # no error (false negative)

foo: C[str] # error (correct)
bar: B[int] # error (correct)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules upstream bug a bug that also exists in pyright but has not been raised upstream
Projects
None yet
Development

No branches or pull requests

2 participants