Closed max-muoto closed 1 month ago
The rules for exponentiation are a bit subtle in python, so I had good reason not to include this operator in pyright's initial implementation of "literal math". I think there are ways we could make this work within some limitations.
I'll note that mypy appears to have a bug where it doesn't apply appropriate limitations and crashes. MY_CONST: Final = 2**100000
. I'll file a bug on this issue.
This will be included in the next release.
This will be included in the next release.
Thanks Eric, super helpful
This is included in pyright 1.1.372.
Similar to https://github.com/microsoft/pyright/issues/8419, it would also be helpful to support exponentiation:
We can also end up with
Any
once we reach2^26
for whatever reason (separate from this, I feel this could lead to subtle bugs):Playground Link
MyPy handles both cases correctly, revealing
Literal[4]
, andLiteral[4294967295]
, so support in Pyright would be nice. At least for me, it's not uncommon to keep constants created through exponentiation, especially when dealing with byte units.