Skip to content

Instantly share code, notes, and snippets.

@relrod
Last active March 9, 2022 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relrod/0794561f1ff7bb25c35fa6d14759729b to your computer and use it in GitHub Desktop.
Save relrod/0794561f1ff7bb25c35fa6d14759729b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from typing import Any
class Foo:
def __init__(self, a: str):
self.a: str = a
def bark(self) -> str:
# can only call upper on str's
return self.a.upper()
foo: Any = 3
reveal_type(foo) # Any
f = Foo(foo)
reveal_type(f.a) # str, even though it isn't
f.bark() # Runtime exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment