Skip to content

Commit

Permalink
Merge pull request #3630 from open-formulieren/issue/registry-typing
Browse files Browse the repository at this point in the history
🏷️ Fix generic type hinting of registry
  • Loading branch information
sergei-maertens authored Nov 27, 2023
2 parents b237275 + 084ed69 commit 52c0e21
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/openforms/plugins/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Callable, Generic, TypeAlias, TypeVar
from typing import TYPE_CHECKING, Callable, Generic, TypeVar

from django.db import OperationalError

Expand All @@ -10,7 +10,6 @@


PluginType_co = TypeVar("PluginType_co", bound="AbstractBasePlugin", covariant=True)
PluginCls: TypeAlias = type[PluginType_co]


class BaseRegistry(Generic[PluginType_co]):
Expand All @@ -32,8 +31,8 @@ def __init__(self):

def __call__(
self, unique_identifier: str, *args, **kwargs
) -> Callable[[PluginCls], PluginCls]:
def decorator(plugin_cls: PluginCls) -> PluginCls:
) -> Callable[[type[PluginType_co]], type[PluginType_co]]:
def decorator(plugin_cls: type[PluginType_co]) -> type[PluginType_co]:
if len(unique_identifier) > UNIQUE_ID_MAX_LENGTH:
raise ValueError(
f"The unique identifier '{unique_identifier}' is longer then {UNIQUE_ID_MAX_LENGTH} characters."
Expand Down

0 comments on commit 52c0e21

Please sign in to comment.