From 4cc579e1828d30fa89c488befaa8a646d4822525 Mon Sep 17 00:00:00 2001 From: Sergei Lebedev Date: Tue, 1 Aug 2023 00:20:32 -0700 Subject: [PATCH] Fixed a latent type error in create_module_from_qualified_name T did not have a bound, so it was invalid to instantiate a value of type `type[T]` with name=. PiperOrigin-RevId: 552711250 --- haiku/_src/module_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/haiku/_src/module_test.py b/haiku/_src/module_test.py index 75cb11abd..1bd7752df 100644 --- a/haiku/_src/module_test.py +++ b/haiku/_src/module_test.py @@ -30,7 +30,7 @@ import jax import jax.numpy as jnp -T = TypeVar("T") +ModuleT = TypeVar("ModuleT", bound=module.Module) # TODO(tomhennigan) Improve test coverage. @@ -1030,8 +1030,8 @@ def __call__(self): def create_module_from_qualified_name( name: str, *, - cls: Type[T] = module.Module, -) -> T: + cls: Type[ModuleT] = module.Module, +) -> ModuleT: if "/" in name: prefix, suffix = name.rsplit("/", 1) with module.name_scope(prefix):