Skip to content

Commit

Permalink
Fixed a latent type error in create_module_from_qualified_name
Browse files Browse the repository at this point in the history
T did not have a bound, so it was invalid to instantiate a value of type
`type[T]` with name=.

PiperOrigin-RevId: 552711250
  • Loading branch information
superbobry authored and copybara-github committed Aug 1, 2023
1 parent 8c64fe5 commit 4cc579e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions haiku/_src/module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4cc579e

Please sign in to comment.