-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typeneeds-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainer
Milestone
Description
In a case like this:
from typing import Any
def f(x: Any):
y: str = x
reveal_type(y)We currently reveal Any because we prefer inferred over declared type. But in this case that's counter productive because our inferred type is just Any.
One policy we could use here is that if the declared type is assignable to the inferred type, that suggests it is at least as precise, and we should prefer it.
AlexWaygood
Metadata
Metadata
Assignees
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typeneeds-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainer