-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
How can I fix typing errors when using this library?
Example:
from abc import ABC, abstractmethod
import inject
class ICache(ABC):
@abstractmethod
def check(self) -> bool:
...
class Cache(ICache):
...
def check(self) -> bool:
return True
def test_inject() -> None:
inject.configure(lambda binder: binder.bind(ICache, Cache())) # type: ignore[arg-type]
cache = inject.instance(ICache)
cache.check()
mypy tests/test_inject.py
tests\test_inject.py:22: error: Item "object" of "object | Any" has no attribute "check" [union-attr]
If I specify the type like this: cache: ICache I get an assignment error instead. How can I resolve this please?
DennisVis and sh-at-cs
Metadata
Metadata
Assignees
Labels
No labels