Conversation
This makes type introspection a bit more complicated but it has the advantage that the name of the type is preserved so in errors you'll see the type name instead of the expansion of the type. It also handles forward references automatically and has several other small ergonomics benefits.
|
|
This is the summary of a private conversation which I had with @hoodmane . from typing import Literal
A = Literal['a', 'b', 'c']
type B = Literal['a', 'b', 'c']
def foo() -> A:
return 'd'
def bar() -> B:
return 'd'gives: i.e., exact same error in both cases. Another thing to keep in mind is that eventually we want to compile this source code with spy itself, and it's unclear if/what the At the same time, the PR is not doing anything harmful and it's "correct". I'll leave it open for a while to give people time to comment if they want. |
This makes type introspection a bit more complicated but it has the advantage that the name of the type is preserved so in errors you'll see the type name instead of the expansion of the type. It also handles forward references automatically and has several other small ergonomics benefits.