Skip to content

Instantly share code, notes, and snippets.

@akaptur
Created December 14, 2021 01:00
Show Gist options
  • Save akaptur/f798cac1cac52a1bbcd5c568effa8817 to your computer and use it in GitHub Desktop.
Save akaptur/f798cac1cac52a1bbcd5c568effa8817 to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
@dataclass
class A:
value: str
@dataclass
class B:
value: str
def my_func(obj: A) -> str:
return obj.value
my_func(B("hi")) # error: Argument 1 to "my_func" has incompatible type "B"; expected "A"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment