pyright
pyright copied to clipboard
Incorrect type for `uuid.UUID.int` (1.1.406 regression, typeshed related)
It's debatable whether this is a typeshed issue or pyright, I suppose. Latest mypy does not exhibit it, using a new typeshed.
import uuid
u = uuid.UUID('')
reveal_type(u.int) # Type of "u.int" is "property"
I'd expect the type to be int.
I'm guessing that this change is downstream of __slots__ being added to UUID (https://github.com/python/typeshed/blob/6547ec10b881acac28ed000a7c2108f8de1c6a1e/stdlib/uuid.pyi#L15)
in https://github.com/python/typeshed/pull/14611.
This is due to a bug in the typeshed stubs. A class is not allowed to have slots definition and a property of the same name. This would not be allowed at runtime.
class Test:
__slots__ = ("foo",)
@property
def foo(self): # ValueError: 'foo' in __slots__ conflicts with class variable
return 1
I've filed a bug report in the typeshed issue tracker.