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

ci(pre-commit.ci): autoupdate #64

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.2.0
rev: v2.3.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand All @@ -19,8 +19,8 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.270
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
hooks:
- id: ruff
args: [--fix]
Expand All @@ -36,7 +36,7 @@ repos:
- id: validate-pyproject

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.4.1
hooks:
- id: mypy
files: "^src/"
4 changes: 2 additions & 2 deletions src/in_n_out/_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def inject(

@overload
def inject(
func: Literal[None] = None,
func: Literal[None] | None = None,
*,
providers: bool = True,
processors: bool = False,
Expand Down Expand Up @@ -259,7 +259,7 @@ def inject_processors(

@overload
def inject_processors(
func: Literal[None] = None,
func: Literal[None] | None = None,
*,
hint: object | type[T] | None = None,
first_processor_only: bool = False,
Expand Down
16 changes: 7 additions & 9 deletions src/in_n_out/_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TYPE_CHECKING,
Any,
Callable,
ClassVar,
ContextManager,
Iterable,
Literal,
Expand All @@ -32,8 +33,6 @@


if TYPE_CHECKING:
from inspect import Signature

from typing_extensions import ParamSpec

from ._type_resolution import RaiseWarnReturnIgnore
Expand Down Expand Up @@ -125,7 +124,7 @@ class Store:
"""A Store is a collection of providers and processors."""

_NULL = _NullSentinel()
_instances: dict[str, Store] = {}
_instances: ClassVar[dict[str, Store]] = {}

@classmethod
def create(cls, name: str) -> Store:
Expand Down Expand Up @@ -613,7 +612,7 @@ def inject(
@overload
def inject(
self,
func: Literal[None] = None,
func: Literal[None] | None = None,
*,
providers: bool = True,
processors: bool = False,
Expand Down Expand Up @@ -773,16 +772,15 @@ def _exec(*args: P.args, **kwargs: P.kwargs) -> R:
args,
kwargs,
)
sig_ = cast("Signature", sig) # mypy thinks sig is still optional

# use bind_partial to allow the caller to still provide their own args
# if desired. (i.e. the injected deps are only used if not provided)
bound = sig_.bind_partial(*args, **kwargs)
bound = sig.bind_partial(*args, **kwargs)
bound.apply_defaults()

# first, get and call the provider functions for each parameter type:
_injected_names: set[str] = set()
for param in sig_.parameters.values():
for param in sig.parameters.values():
if param.name not in bound.arguments:
provided = self.provide(param.annotation)
if provided is not None:
Expand Down Expand Up @@ -815,7 +813,7 @@ def _exec(*args: P.args, **kwargs: P.kwargs) -> R:
else "NO arguments"
)
logger.exception(e)
for param in sig_.parameters.values():
for param in sig.parameters.values():
if (
param.name not in bound.arguments
and param.default is param.empty
Expand Down Expand Up @@ -873,7 +871,7 @@ def inject_processors(
@overload
def inject_processors(
self,
func: Literal[None] = None,
func: Literal[None] | None = None,
*,
type_hint: object | type[T] | None = None,
first_processor_only: bool = False,
Expand Down
Loading