0

I want to create a some kind of abstract class with only attributes.
The concrete class should have all the attributes of abstract class.
I never creating instances of these classes, it's mostly to reflect a hierarchy
and get warnings from IDE if some attribute of base class are missed.

It's just like abstract class but only for attributes instead of methods.
How I can do it?

It's may be SimpleNamespace, Enum, dataclass, etc. The main part is warnings.

usage example:

def translator(abstract_attribute, concrete_class):
    return getattr(concrete_class, abstract_attribute)

I tried:

from abc import ABC
from enum import Enum, auto


class Abstract(Enum):
    FOO = auto()

class Concreate(Abstract):
    FOO = 'some_value'

TypeError: Concreate: cannot extend enumeration 'Abstract'
class Abstract(ABC, Enum):
    FOO = auto()

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

P.S. I tried this answer but this is not are the case apparently. Create an abstract Enum class

salius
  • 918
  • 1
  • 14
  • 30

0 Answers0