Skip to content

Commit

Permalink
Fix Lint (#5735)
Browse files Browse the repository at this point in the history
Signed-off-by: Tenshin Higashi <[email protected]>
  • Loading branch information
tenshinhigashi authored Aug 7, 2024
1 parent 70cfbfb commit eb81760
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/ambassador/fetch/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Type,
TypeVar,
)
from typing import cast as typecast

from .k8sobject import KubernetesObject, KubernetesObjectKey

Expand Down Expand Up @@ -181,7 +182,12 @@ class DependencyManager:
injectors: Mapping[Any, DependencyInjector]

def __init__(self, deps: Collection[D]) -> None:
self.deps = {dep.__class__: dep for dep in deps}
# DependencyMapping requires __contains__ and __getitem__ to be
# defined, which dicts do -- however, DependencyMapping also
# requires that the argument to those two methods be a Type[D],
# which dicts do not. MyPy doesn't like this, so we have to cast
# the dict to the correct type.
self.deps = typecast(DependencyMapping, {dep.__class__: dep for dep in deps})
self.injectors = defaultdict(lambda: DependencyInjector(self.deps))

def for_instance(self, obj: Any) -> DependencyInjector:
Expand Down

0 comments on commit eb81760

Please sign in to comment.