Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add annotations for resolve container #193

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions punq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
from collections import defaultdict
from enum import Enum
from importlib.metadata import PackageNotFoundError, version
from typing import Any, Callable, NamedTuple, get_type_hints
from typing import Any, Callable, NamedTuple, get_type_hints, TypeVar, Type

from ._compat import ensure_forward_ref, is_generic_list

T = TypeVar('T')

with contextlib.suppress(PackageNotFoundError):
__version__ = version(__name__)

Expand Down Expand Up @@ -508,7 +510,7 @@ def _resolve_impl(self, service_key, kwargs, context, default=None):

return self._build_impl(registration, kwargs, context)

def resolve(self, service_key, **kwargs):
def resolve(self, service_key: Type[T], **kwargs) -> T:
"""Build and return an instance of a registered service."""
context = self.registrations.build_context(service_key)

Expand Down