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

False negative when quoted type appears in union syntax with UnionType operand #9500

Open
brianschubert opened this issue Nov 23, 2024 · 1 comment
Labels
enhancement request New feature or request

Comments

@brianschubert
Copy link

Describe the bug

Pyright does not reject quoted types in union syntax when combined with a UnionType operand.

Code or Screenshots

[pyright playground]

x1: int | "str"          # E: Union syntax cannot be used with string operand; use quotes around entire expression 
x2: int | str | "bytes"  # Runtime error, no pyright error

U: TypeAlias = int | str
x3: U | "bytes"          # Runtime error, no pyright error
x4: "bytes" | U          # Runtime error, no pyright error

Command-line

$ pyright example.py
example.py
 example.py:1:11 - error: Union syntax cannot be used with string operand; use quotes around entire expression (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations 

$ pyright --version
pyright 1.1.389
@brianschubert brianschubert added the bug Something isn't working label Nov 23, 2024
@erictraut
Copy link
Collaborator

This isn't really a type error, but I think it's a reasonable enhancement request.

@erictraut erictraut added enhancement request New feature or request and removed bug Something isn't working labels Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants