File: inheritance.py

package info (click to toggle)
python-beanie 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,484 kB
  • sloc: python: 14,427; makefile: 6; sh: 6
file content (19 lines) | stat: -rw-r--r-- 448 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from typing import (
    ClassVar,
    Dict,
    Optional,
    Type,
)


class InheritanceInterface:
    _children: ClassVar[Dict[str, Type]]
    _parent: ClassVar[Optional[Type]]
    _inheritance_inited: ClassVar[bool]
    _class_id: ClassVar[Optional[str]] = None

    @classmethod
    def add_child(cls, name: str, clas: Type):
        cls._children[name] = clas
        if cls._parent is not None:
            cls._parent.add_child(name, clas)