-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Bug in handling overloads #3575
Comments
This is correct behavior. A |
This isn't correct behaviour. Overloads for true and false are a completely containing set of the domain of (Further, you'll note the base function definition does contain the bool signature) |
There are cases where the contract for an overloaded function calls for passing either a literal The implementation signature is not used for purposes of type checking calls that target an overload. |
Even given the rest (which I'd still argue specifying every value of a domain obviates a redundant definition of the domain itself, for any domain; just bool is the trivial version)
seems like a glaring violation of DRY. |
The behavior of overloads is specified in the PEP 484 standard that dictates the behaviors of Python type checkers. If you feel strongly about it, you could propose and shepherd a change to the standard. I think it's likely to be accepted though because the current behavior has utility, and changing it would have backward compatibility implications for existing code bases. |
I recently submitted a draft update to the Python typing spec that clarifies the type checker behaviors for argument type expansion when evaluating calls to overloaded functions. The draft spec includes expansion of This draft update hasn't yet been approved by the full Typing Council, but I think there's a good chance it will be in the near future. |
Describe the bug
An overloaded function with return specifications based on literal True/False will raise a type error on wrappers passing a bool
To Reproduce
Full example below
Expected behavior
Account for all the overloads
Screenshots or Code
If your code relies on symbols that are imported from a third-party library, include the associated import statements and specify which versions of those libraries you have installed.
VS Code extension or command-line
vscode pylance extension:
v2022.06.10
The text was updated successfully, but these errors were encountered: