Skip to content

prefer declared type over inferred type #136

@carljm

Description

@carljm

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.

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions