Last active
March 9, 2022 21:14
-
-
Save relrod/0794561f1ff7bb25c35fa6d14759729b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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