From f1c3346a552e010b2364a35198141fb2dc418e82 Mon Sep 17 00:00:00 2001 From: octo-gone Date: Sat, 10 Aug 2024 22:49:15 +0300 Subject: [PATCH] feat: update typing for register --- pyproject.toml | 2 +- src/jinja2_components/__init__.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f4e2e34..0158d34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "jinja2-components" -version = "0.0.3" +version = "0.0.4" description = "Streamlined way to build and reuse your Jinja2 templates from code" authors = ["octo-gone "] readme = "README.md" diff --git a/src/jinja2_components/__init__.py b/src/jinja2_components/__init__.py index 432e8f5..2a873c6 100644 --- a/src/jinja2_components/__init__.py +++ b/src/jinja2_components/__init__.py @@ -4,12 +4,14 @@ from jinja2_components.component import Component from jinja2_components.ext import ComponentsExtension +TComponent = t.TypeVar("TComponent", bound=Component) + def register( name: str, ext_base_cls: t.Type[ComponentsExtension] = ComponentsExtension, ): - def _register_component(cls: t.Type[Component]): + def _register_component(cls: t.Type[TComponent]) -> t.Type[TComponent]: ext_base_cls.tags.add(name) ext_base_cls.components[name] = cls return cls