[New-bugs-announce] [issue43243] Strict ABC classes
report at bugs.python.org
Wed Feb 17 12:28:12 EST 2021
New submission from Yurii Karabas <1998uriyyo at gmail.com>:
Basically, the idea is to add the ability to mark abstract classes as strict.
What does this mean - in case when a class inherits from a strict abstract base class and doesn't implement all abstract methods then it will fail to create a class.
>>> class Iterable(ABC, strict=True):
... def __iter__(self):
>>> class MyClass(Iterable):
TypeError: Can't create class MyClass with unimplemented strict abstract method __iter__
That allows creating abc classes and be sure that class defines a required method, it will be perfrormed on a class declaration stage rather than class instance creation.
components: Library (Lib)
title: Strict ABC classes
versions: Python 3.10
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce