Small library for registry and instantiation of extensions.
Example
from extensible import Extensible, Option, OptionType
class Printer(Extensible, is_base=True):
extension_type = "printer"
pass
class PrettyPrinter(Printer):
extension_name = "pretty"
extension_options = [
Option("indent", OptionType.int, default=4)
]
indent: int
def __init__(self, indent: int) -> None:
self.indent = indent
Instantiation:
printer: Printer
printer = Printer.concrete_extension("pretty") \
.create_with_dict({"indent": "10"})
Author: Stefan Urbanek [email protected] License: MIT