Improve .traverse() typing stubs

This commit is contained in:
Roman Mogylatov 2021-02-05 17:49:16 -05:00
parent 78f623c05b
commit b4ac08819e
3 changed files with 10 additions and 3 deletions

View File

@ -7,6 +7,11 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
Development version
-------------------
- Improve ``container.traverse(types=[...])`` and ``provider.traverse(types=[...])`` typing stubs
to return ``types`` -typed iterator.
4.18.0
------
- Add ``container.reset_singleton()`` method to reset container singletons.

View File

@ -21,6 +21,7 @@ from .providers import Provider
C_Base = TypeVar('C_Base', bound='Container')
C = TypeVar('C', bound='DeclarativeContainer')
C_Overriding = TypeVar('C_Overriding', bound='DeclarativeContainer')
TT = TypeVar('TT')
class Container:
@ -46,10 +47,10 @@ class Container:
def apply_container_providers_overridings(self) -> None: ...
def reset_singletons(self) -> None: ...
@overload
def traverse(self, types: Optional[Sequence[Type]] = None) -> Iterator[Provider]: ...
def traverse(self, types: Optional[Sequence[TT]] = None) -> Iterator[TT]: ...
@classmethod
@overload
def traverse(cls, types: Optional[Sequence[Type]] = None) -> Iterator[Provider]: ...
def traverse(cls, types: Optional[Sequence[TT]] = None) -> Iterator[TT]: ...
class DynamicContainer(Container): ...

View File

@ -36,6 +36,7 @@ from . import resources
Injection = Any
T = TypeVar('T')
TT = TypeVar('TT')
class OverridingContext:
@ -76,7 +77,7 @@ class Provider(Generic[T]):
def is_async_mode_undefined(self) -> bool: ...
@property
def related(self) -> _Iterator[Provider]: ...
def traverse(self, types: Optional[_Iterable[Type]] = None) -> _Iterator[Provider]: ...
def traverse(self, types: Optional[_Iterable[TT]] = None) -> _Iterator[TT]: ...
def _copy_overridings(self, copied: Provider, memo: Optional[_Dict[Any, Any]]) -> None: ...