Skip to content

Commit 009a86d

Browse files
committed
Imporve dict typings
1 parent 18e3252 commit 009a86d

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/dependency_injector/providers.pyi

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
from __future__ import annotations
22

3-
from contextlib import AbstractContextManager, AbstractAsyncContextManager
3+
from contextlib import AbstractAsyncContextManager, AbstractContextManager
44
from pathlib import Path
55
from typing import (
6+
Any,
7+
AsyncIterator as _AsyncIterator,
68
Awaitable,
7-
Generic,
8-
Type,
99
Callable as _Callable,
10-
Any,
11-
Tuple,
12-
List as _List,
13-
Dict as _Dict,
14-
Optional,
15-
Union,
1610
Coroutine as _Coroutine,
11+
Dict as _Dict,
12+
Generator as _Generator,
13+
Generic,
1714
Iterable as _Iterable,
1815
Iterator as _Iterator,
19-
AsyncIterator as _AsyncIterator,
20-
Generator as _Generator,
16+
List as _List,
17+
Mapping,
18+
Optional,
19+
Tuple,
20+
Type,
21+
Union,
2122
overload,
2223
)
2324

@@ -68,7 +69,7 @@ class Provider(Generic[T]):
6869
@property
6970
def provider(self) -> Provider[T]: ...
7071
@property
71-
def provided(self) -> ProvidedInstance[T]: ...
72+
def provided(self) -> ProvidedInstance: ...
7273
def enable_async_mode(self) -> None: ...
7374
def disable_async_mode(self) -> None: ...
7475
def reset_async_mode(self) -> None: ...
@@ -106,7 +107,7 @@ class Delegate(Provider[Provider]):
106107
class Aggregate(Provider[T]):
107108
def __init__(
108109
self,
109-
provider_dict: Optional[_Dict[Any, Provider[T]]] = None,
110+
provider_dict: Optional[Mapping[Any, Provider[T]]] = None,
110111
**provider_kwargs: Provider[T],
111112
): ...
112113
def __getattr__(self, provider_name: Any) -> Provider[T]: ...
@@ -125,7 +126,7 @@ class Aggregate(Provider[T]):
125126
def providers(self) -> _Dict[Any, Provider[T]]: ...
126127
def set_providers(
127128
self,
128-
provider_dict: Optional[_Dict[Any, Provider[T]]] = None,
129+
provider_dict: Optional[Mapping[Any, Provider[T]]] = None,
129130
**provider_kwargs: Provider[T],
130131
) -> Aggregate[T]: ...
131132

@@ -183,7 +184,7 @@ class Callable(Provider[T]):
183184
def set_args(self, *args: Injection) -> Callable[T]: ...
184185
def clear_args(self) -> Callable[T]: ...
185186
@property
186-
def kwargs(self) -> _Dict[Any, Injection]: ...
187+
def kwargs(self) -> _Dict[str, Injection]: ...
187188
def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
188189
def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
189190
def clear_kwargs(self) -> Callable[T]: ...
@@ -355,7 +356,7 @@ class Factory(Provider[T]):
355356
def set_args(self, *args: Injection) -> Factory[T]: ...
356357
def clear_args(self) -> Factory[T]: ...
357358
@property
358-
def kwargs(self) -> _Dict[Any, Injection]: ...
359+
def kwargs(self) -> _Dict[str, Injection]: ...
359360
def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
360361
def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
361362
def clear_kwargs(self) -> Factory[T]: ...
@@ -379,7 +380,7 @@ class FactoryAggregate(Aggregate[T]):
379380
def factories(self) -> _Dict[Any, Factory[T]]: ...
380381
def set_factories(
381382
self,
382-
provider_dict: Optional[_Dict[Any, Factory[T]]] = None,
383+
provider_dict: Optional[Mapping[Any, Factory[T]]] = None,
383384
**provider_kwargs: Factory[T],
384385
) -> FactoryAggregate[T]: ...
385386

@@ -404,7 +405,7 @@ class BaseSingleton(Provider[T]):
404405
def set_args(self, *args: Injection) -> BaseSingleton[T]: ...
405406
def clear_args(self) -> BaseSingleton[T]: ...
406407
@property
407-
def kwargs(self) -> _Dict[Any, Injection]: ...
408+
def kwargs(self) -> _Dict[str, Injection]: ...
408409
def add_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
409410
def set_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
410411
def clear_kwargs(self) -> BaseSingleton[T]: ...
@@ -440,15 +441,15 @@ class List(Provider[_List]):
440441

441442
class Dict(Provider[_Dict]):
442443
def __init__(
443-
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection
444+
self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
444445
): ...
445446
@property
446447
def kwargs(self) -> _Dict[Any, Injection]: ...
447448
def add_kwargs(
448-
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection
449+
self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
449450
) -> Dict: ...
450451
def set_kwargs(
451-
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection
452+
self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
452453
) -> Dict: ...
453454
def clear_kwargs(self) -> Dict: ...
454455

@@ -518,7 +519,7 @@ class Resource(Provider[T]):
518519
def set_args(self, *args: Injection) -> Resource[T]: ...
519520
def clear_args(self) -> Resource[T]: ...
520521
@property
521-
def kwargs(self) -> _Dict[Any, Injection]: ...
522+
def kwargs(self) -> _Dict[str, Injection]: ...
522523
def add_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
523524
def set_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
524525
def clear_kwargs(self) -> Resource[T]: ...

0 commit comments

Comments
 (0)