Last active
December 14, 2021 01:03
-
-
Save akaptur/93756c965c56514be7f1abc9afe98f0d 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
from typing import Protocol | |
class MyProto(Protocol): | |
value: str | |
@dataclass | |
class A: | |
value: str | |
@dataclass | |
class B: | |
value: str | |
image: str | |
def my_func(obj: MyProto) -> str: # note the changed the type annotation | |
return obj.value | |
my_func(B("hi", "a gzipped photo of a cat")) # no error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment