Skip to content

Type "floating[Any]" is not assignable to return type "T@f" #6590

Answered by erictraut
allanleal asked this question in Q&A
Discussion options

You must be logged in to vote

As I said above, there is no inference going on here. Pyright is simply applying standard type evaluation rules. There's nothing to "address" here because pyright is behaving correctly as a static type checker. If we were to change its behavior as you're suggesting, it would no longer be compliant with the Python typing spec, and it wouldn't correctly reflect what happens at runtime.

Let's take a closer look at the example above where you're using multiplication with a value whose type is described by a type variable with an upper bound of float. The * operator invokes the float.__mul__ method. The type information for this method can be found in the builtins.pyi type stub file, part of t…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@allanleal
Comment options

@erictraut
Comment options

Answer selected by allanleal
@allanleal
Comment options

@allanleal
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants