Bug Report
When passing a single strategized type expression to a function accepting a TypeForm argument, which cannot be fully resolved, due to e.g. a missing import, we get an arg-type error of the form:
Instead of an error, telling us why the type expression is invalid.
To Reproduce
https://mypy-play.net/?mypy=master&python=3.14&gist=891447236311046360886ba63c1fac83
from typing_extensions import TypeForm
def foo[T](x: TypeForm[T]) -> None:
pass
foo("Unresolvable")
Expected Behavior
mypy should emit a name-error for Unresolvable, since it was never defined. The given example is probably the most controversial case though, since someone may actually accidentally be passing an invalid string literal, but the same thing happens for less controversial cases like "list[Unresolvable]". But I think either way it makes more sense to treat the given string literal as a type expression and emit the same errors you would emit if you saw the same string literal in an annotation.
Actual Behavior
error: Argument 1 to "foo" has incompatible type "str"; expected "TypeForm[Never]" [arg-type]
This error does not help us solve the problem in our code at all.
Your Environment
- Mypy version used: 2.2
- Python version used: 3.14
Bug Report
When passing a single strategized type expression to a function accepting a
TypeFormargument, which cannot be fully resolved, due to e.g. a missing import, we get anarg-typeerror of the form:Instead of an error, telling us why the type expression is invalid.
To Reproduce
https://mypy-play.net/?mypy=master&python=3.14&gist=891447236311046360886ba63c1fac83
Expected Behavior
mypy should emit a
name-errorforUnresolvable, since it was never defined. The given example is probably the most controversial case though, since someone may actually accidentally be passing an invalid string literal, but the same thing happens for less controversial cases like"list[Unresolvable]". But I think either way it makes more sense to treat the given string literal as a type expression and emit the same errors you would emit if you saw the same string literal in an annotation.Actual Behavior
This error does not help us solve the problem in our code at all.
Your Environment