Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
fix: Fix unsafe | operand round 2
Browse files Browse the repository at this point in the history
  • Loading branch information
lsetiawan committed Feb 23, 2024
1 parent 0a70212 commit 3f99093
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/caustics/models/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class _KindRegistry(MutableMapping[str, "Parametrized | str"]):
}

def __init__(self) -> None:
self._m: ChainMap[str, Parametrized | str] = ChainMap({}, self.known_kinds) # type: ignore
self._m: ChainMap[str, "Parametrized | str"] = ChainMap({}, self.known_kinds) # type: ignore

def __getitem__(self, item: str) -> Parametrized:
kind_mod: str | Parametrized | None = self._m.get(item, None)
kind_mod: "str | Parametrized | None" = self._m.get(item, None)

Check warning on line 33 in src/caustics/models/registry.py

View check run for this annotation

Codecov / codecov/patch

src/caustics/models/registry.py#L33

Added line #L33 was not covered by tests
if kind_mod is None:
raise KeyError(f"{item} not in registry")
if isinstance(kind_mod, str):
Expand All @@ -39,7 +39,7 @@ def __getitem__(self, item: str) -> Parametrized:
cls = getattr(mod, name) # type: ignore
return cls

def __setitem__(self, item: str, value: Parametrized | str) -> None:
def __setitem__(self, item: str, value: "Parametrized | str") -> None:
if not (
(isinstance(value, type) and issubclass(value, Parametrized))
or isinstance(value, str)
Expand Down Expand Up @@ -71,7 +71,7 @@ def available_kinds() -> list[str]:

def register_kind(
name: str,
cls: Parametrized | str,
cls: "Parametrized | str",
*,
clobber: bool = False,
) -> None:
Expand All @@ -96,7 +96,7 @@ def register_kind(
@lru_cache
def get_kind(
name: str,
) -> Parametrized | None:
) -> Parametrized:
"""Get a class from the registry by name.
Parameters
Expand Down

0 comments on commit 3f99093

Please sign in to comment.