Skip to content

Instantly share code, notes, and snippets.

@IgorZyktin
Created November 1, 2021 17:05
Show Gist options
  • Save IgorZyktin/9a5a6589e78335c9e21bea81d176bbdc to your computer and use it in GitHub Desktop.
Save IgorZyktin/9a5a6589e78335c9e21bea81d176bbdc to your computer and use it in GitHub Desktop.
from abc import ABC, abstractmethod
class A(ABC):
@property
@abstractmethod
def attr(self) -> str:
...
class B:
attr: str
class C(A):
def __init__(self):
self.attr = '25'
a = A() # TypeError: Can't instantiate abstract class A with abstract methods attr
b = B()
b.attr # AttributeError: 'B' object has no attribute 'attr'
c = C() # AttributeError: 'B' object has no attribute 'attr'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment