basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Render `Any` subtypes

Open DetachHead opened this issue 3 years ago • 2 comments

class A(Any): ...
reveal_type(A()) # A

This could reveal something like A(Any) or Any(A) or Any[A]

class A:
  def __getattr__(...) -> Any: ...
a: A
reveal_type(a.foo) # Any

This could mention that the signature of foo is actually comming from an operator.

Original Content

import tempfile
from os import PathLike

with tempfile.NamedTemporaryFile() as file:
    reveal_type(file) # tempfile._TemporaryFileWrapper[builtins.bytes]
    foo: PathLike[str] = file # no error even though it's not a PathLike

DetachHead avatar May 16 '22 10:05 DetachHead

it wwould also be useful if the error provided some information as to what's causing it

DetachHead avatar May 16 '22 10:05 DetachHead

The source of the Any would be good to show. In this case it's an Any __getattr__.

KotlinIsland avatar May 16 '22 11:05 KotlinIsland