Flask used decorators to register routes handlers. I have another post about flask internal to match function to specific URI.

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

That said, I wanted to implement similar registration but for classes.

class Block():
    def __init__(self) -> None:
        pass

class Env():
    _blocks = []

    def __init__(self) -> None:
        pass

    @classmethod
    def register(cls):
        def decorator(fn):
            cls._blocks.append(fn)
            return fn
        return decorator

@Env.register()
class block1(Block):
    pass

env = Env()

print(env._blocks)

which prints

[<class '__main__.block1'>]