bare literal types
foo: True
bar: 1 | 2
and Enums
This would be really nice for typing fixed-size arrays/vectors/matrices/etc.
Similarly, supporting Ellipses ... would be quite useful.
Is this on the roadmap?
adding non-standard syntax like this isn't super high priority for me, i consider fixing false positives/false negatives and language server features to be more important. however if someone wants to implement it a PR is welcome, as long as there's an option to ban it for users who either can't or don't want to use non-standard syntax in their projects
pyright already supports bare literals:
class A[T]:
def __init__(self, t: T) -> None:
pass
B = A[1]
b: B = A(2)
that behavior is not intentional and is therefore completely broken
Code sample in basedpyright playground
class A[T]:
def __init__(self, t: T) -> None:
pass
B = A[1 | 2]
b: B = A(2) # error: "int" is not assignable to type "Literal[3]"