Consider this contrived example;
@dataclass
class A:
name: str = "John"
....
@dataclass
class B:
name: str = "Doe"
Q: How do I type hint an object that has an attribute, such as the following?
def print_name(obj: HasAttr['name'])
print(obj.name)
I understand the SO rule on showing what you have tried. The best I can offer is that I've searched the docs; Pep526, PythonSheets, Docs, and am aware of this SO Question. None seem to help (or maybe I missed it.)
[Edit] I recognize that you can get there with inheritance, but I don't want to go that route.