Set Registry name parameter to Hashable type (#51203)

This commit is contained in:
Martin Hjelmare 2021-05-28 15:29:11 +02:00 committed by GitHub
parent 0fbdce5ca6
commit 187374c11e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
"""Decorator utility functions."""
from collections.abc import Hashable
from typing import Callable, TypeVar
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
@ -7,7 +8,7 @@ CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-na
class Registry(dict):
"""Registry of items."""
def register(self, name: str) -> Callable[[CALLABLE_T], CALLABLE_T]:
def register(self, name: Hashable) -> Callable[[CALLABLE_T], CALLABLE_T]:
"""Return decorator to register item with a specific name."""
def decorator(func: CALLABLE_T) -> CALLABLE_T: