You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pyright xdsl/dialects/bla.py
12:1 - error: Type of "val" is unknown (reportUnknownVariableType)
12:7 - error: Type of "method" is partially unknown
Type of "method" is "(param: Unknown) -> Unknown" (reportUnknownMemberType)
2 errors, 0 warnings, 0 informations
With pyright 1.1.384
The text was updated successfully, but these errors were encountered:
Pyright's behavior here is correct, so this isn't a bug.
You've defined a class-scoped type variable here, so the type argument is associated with the class (GenericClass), not with the method (method). Any class-scoped type variables that appear within a method's signature are specialized at the time you access the method through the class. In this case, the class is GenericClass[Unknown] because you haven't provided an explicit type argument. If you had provided a default value for the type variable (as per PEP 696), then GenericClass would be specialized with that default value. Since there was no default specified, the default is implicitly Unknown. That means the type of GenericClass.method is (param: Unknown) -> Unknown. There is no type variable to solve in this case, so it doesn't matter what arguments you pass.
There's only one case specified in the typing spec where class-scoped type variables can be inferred when calling a method, and that's in the case of a constructor call. This special case doesn't apply to class methods.
Here's a simple example, T is completely specified, yet Pyright complains:
Pyright errors:
With
pyright 1.1.384
The text was updated successfully, but these errors were encountered: