Imporve dict typings

This commit is contained in:
ZipFile 2025-11-01 13:04:53 +00:00
parent 18e32521a0
commit 009a86de2c

View File

@ -1,23 +1,24 @@
from __future__ import annotations from __future__ import annotations
from contextlib import AbstractContextManager, AbstractAsyncContextManager from contextlib import AbstractAsyncContextManager, AbstractContextManager
from pathlib import Path from pathlib import Path
from typing import ( from typing import (
Awaitable,
Generic,
Type,
Callable as _Callable,
Any, Any,
Tuple, AsyncIterator as _AsyncIterator,
List as _List, Awaitable,
Dict as _Dict, Callable as _Callable,
Optional,
Union,
Coroutine as _Coroutine, Coroutine as _Coroutine,
Dict as _Dict,
Generator as _Generator,
Generic,
Iterable as _Iterable, Iterable as _Iterable,
Iterator as _Iterator, Iterator as _Iterator,
AsyncIterator as _AsyncIterator, List as _List,
Generator as _Generator, Mapping,
Optional,
Tuple,
Type,
Union,
overload, overload,
) )
@ -68,7 +69,7 @@ class Provider(Generic[T]):
@property @property
def provider(self) -> Provider[T]: ... def provider(self) -> Provider[T]: ...
@property @property
def provided(self) -> ProvidedInstance[T]: ... def provided(self) -> ProvidedInstance: ...
def enable_async_mode(self) -> None: ... def enable_async_mode(self) -> None: ...
def disable_async_mode(self) -> None: ... def disable_async_mode(self) -> None: ...
def reset_async_mode(self) -> None: ... def reset_async_mode(self) -> None: ...
@ -106,7 +107,7 @@ class Delegate(Provider[Provider]):
class Aggregate(Provider[T]): class Aggregate(Provider[T]):
def __init__( def __init__(
self, self,
provider_dict: Optional[_Dict[Any, Provider[T]]] = None, provider_dict: Optional[Mapping[Any, Provider[T]]] = None,
**provider_kwargs: Provider[T], **provider_kwargs: Provider[T],
): ... ): ...
def __getattr__(self, provider_name: Any) -> Provider[T]: ... def __getattr__(self, provider_name: Any) -> Provider[T]: ...
@ -125,7 +126,7 @@ class Aggregate(Provider[T]):
def providers(self) -> _Dict[Any, Provider[T]]: ... def providers(self) -> _Dict[Any, Provider[T]]: ...
def set_providers( def set_providers(
self, self,
provider_dict: Optional[_Dict[Any, Provider[T]]] = None, provider_dict: Optional[Mapping[Any, Provider[T]]] = None,
**provider_kwargs: Provider[T], **provider_kwargs: Provider[T],
) -> Aggregate[T]: ... ) -> Aggregate[T]: ...
@ -183,7 +184,7 @@ class Callable(Provider[T]):
def set_args(self, *args: Injection) -> Callable[T]: ... def set_args(self, *args: Injection) -> Callable[T]: ...
def clear_args(self) -> Callable[T]: ... def clear_args(self) -> Callable[T]: ...
@property @property
def kwargs(self) -> _Dict[Any, Injection]: ... def kwargs(self) -> _Dict[str, Injection]: ...
def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ... def add_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ... def set_kwargs(self, **kwargs: Injection) -> Callable[T]: ...
def clear_kwargs(self) -> Callable[T]: ... def clear_kwargs(self) -> Callable[T]: ...
@ -355,7 +356,7 @@ class Factory(Provider[T]):
def set_args(self, *args: Injection) -> Factory[T]: ... def set_args(self, *args: Injection) -> Factory[T]: ...
def clear_args(self) -> Factory[T]: ... def clear_args(self) -> Factory[T]: ...
@property @property
def kwargs(self) -> _Dict[Any, Injection]: ... def kwargs(self) -> _Dict[str, Injection]: ...
def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ... def add_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ... def set_kwargs(self, **kwargs: Injection) -> Factory[T]: ...
def clear_kwargs(self) -> Factory[T]: ... def clear_kwargs(self) -> Factory[T]: ...
@ -379,7 +380,7 @@ class FactoryAggregate(Aggregate[T]):
def factories(self) -> _Dict[Any, Factory[T]]: ... def factories(self) -> _Dict[Any, Factory[T]]: ...
def set_factories( def set_factories(
self, self,
provider_dict: Optional[_Dict[Any, Factory[T]]] = None, provider_dict: Optional[Mapping[Any, Factory[T]]] = None,
**provider_kwargs: Factory[T], **provider_kwargs: Factory[T],
) -> FactoryAggregate[T]: ... ) -> FactoryAggregate[T]: ...
@ -404,7 +405,7 @@ class BaseSingleton(Provider[T]):
def set_args(self, *args: Injection) -> BaseSingleton[T]: ... def set_args(self, *args: Injection) -> BaseSingleton[T]: ...
def clear_args(self) -> BaseSingleton[T]: ... def clear_args(self) -> BaseSingleton[T]: ...
@property @property
def kwargs(self) -> _Dict[Any, Injection]: ... def kwargs(self) -> _Dict[str, Injection]: ...
def add_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ... def add_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
def set_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ... def set_kwargs(self, **kwargs: Injection) -> BaseSingleton[T]: ...
def clear_kwargs(self) -> BaseSingleton[T]: ... def clear_kwargs(self) -> BaseSingleton[T]: ...
@ -440,15 +441,15 @@ class List(Provider[_List]):
class Dict(Provider[_Dict]): class Dict(Provider[_Dict]):
def __init__( def __init__(
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
): ... ): ...
@property @property
def kwargs(self) -> _Dict[Any, Injection]: ... def kwargs(self) -> _Dict[Any, Injection]: ...
def add_kwargs( def add_kwargs(
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
) -> Dict: ... ) -> Dict: ...
def set_kwargs( def set_kwargs(
self, dict_: Optional[_Dict[Any, Injection]] = None, **kwargs: Injection self, dict_: Optional[Mapping[Any, Injection]] = None, **kwargs: Injection
) -> Dict: ... ) -> Dict: ...
def clear_kwargs(self) -> Dict: ... def clear_kwargs(self) -> Dict: ...
@ -518,7 +519,7 @@ class Resource(Provider[T]):
def set_args(self, *args: Injection) -> Resource[T]: ... def set_args(self, *args: Injection) -> Resource[T]: ...
def clear_args(self) -> Resource[T]: ... def clear_args(self) -> Resource[T]: ...
@property @property
def kwargs(self) -> _Dict[Any, Injection]: ... def kwargs(self) -> _Dict[str, Injection]: ...
def add_kwargs(self, **kwargs: Injection) -> Resource[T]: ... def add_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
def set_kwargs(self, **kwargs: Injection) -> Resource[T]: ... def set_kwargs(self, **kwargs: Injection) -> Resource[T]: ...
def clear_kwargs(self) -> Resource[T]: ... def clear_kwargs(self) -> Resource[T]: ...