Relative Content

Tag Archive for pythonoop

How to make a Protocol that inherits methods and attributes from a concrete class

Scenario I have a Foo protocol: class Foo(Protocol): fooname: str def do_fooey_things(self): pass and a bunch of different types of concrete Foos: class PurpleFoo: fooname: str = “purple” def do_fooey_things(self): print(“purple foo!”) What I’ve achieved with this is a way of being able to type-hint, have my IDE help me, and run tests to make […]