Skip to content

Commit 5ff7490

Browse files
authored
Minor renames
1 parent 8ddeb84 commit 5ff7490

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

injection/_core/asfunction.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, Protocol
55

66
from injection._core.common.asynchronous import Caller
7-
from injection._core.module import Module, mod
7+
from injection._core.module import InjectMetadata, Module, mod
88

99

1010
class _AsFunctionCallable[**P, T](Protocol):
@@ -23,15 +23,14 @@ def asfunction[**P, T](
2323
) -> Any:
2424
def decorator(wp: AsFunctionWrappedType[P, T]) -> Callable[P, T]:
2525
fake_method = wp.__call__.__get__(NotImplemented, wp)
26-
factory: Caller[..., Callable[P, T]] = (module or mod())._metadata(
27-
wp,
28-
threadsafe,
29-
)
26+
metadata: InjectMetadata[..., Callable[P, T]] = (
27+
module or mod()
28+
).create_metadata(wp, threadsafe)
3029

3130
wrapper: Callable[P, T] = (
32-
_wrap_async(factory) # type: ignore[arg-type, assignment]
31+
_wrap_async(metadata) # type: ignore[arg-type, assignment]
3332
if iscoroutinefunction(fake_method)
34-
else _wrap_sync(factory)
33+
else _wrap_sync(metadata)
3534
)
3635
wrapper = update_wrapper(wrapper, fake_method)
3736

injection/_core/module.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,14 @@ def decorator(wp: Callable[P, T]) -> Callable[P, T]:
363363

364364
return decorator(wrapped) if wrapped else decorator
365365

366+
def create_metadata[**P, T](
367+
self,
368+
wrapped: Callable[P, T],
369+
/,
370+
threadsafe: bool | None = None,
371+
) -> InjectMetadata[P, T]:
372+
return InjectMetadata(wrapped, threadsafe).listen(self)
373+
366374
if TYPE_CHECKING: # pragma: no cover
367375

368376
@overload
@@ -387,7 +395,7 @@ def make_injected_function[**P, T](
387395
/,
388396
threadsafe: bool | None = None,
389397
) -> InjectedFunction[P, T]:
390-
metadata = self._metadata(wrapped, threadsafe)
398+
metadata = self.create_metadata(wrapped, threadsafe)
391399

392400
if iscoroutinefunction(wrapped):
393401
return AsyncInjectedFunction(metadata) # type: ignore[arg-type, return-value]
@@ -400,7 +408,7 @@ def make_async_factory[T](
400408
/,
401409
threadsafe: bool | None = None,
402410
) -> Callable[..., Awaitable[T]]:
403-
return self._metadata(wrapped, threadsafe).acall
411+
return self.create_metadata(wrapped, threadsafe).acall
404412

405413
async def afind_instance[T](
406414
self,
@@ -514,7 +522,7 @@ def aget_lazy_instance[T, Default](
514522
threadsafe: bool | None = None,
515523
) -> Awaitable[T | Default]:
516524
return SimpleAwaitable(
517-
self._metadata(
525+
self.create_metadata(
518526
lambda instance=default: instance,
519527
threadsafe=threadsafe,
520528
)
@@ -550,7 +558,7 @@ def get_lazy_instance[T, Default](
550558
threadsafe: bool | None = None,
551559
) -> Invertible[T | Default]:
552560
return SimpleInvertible(
553-
self._metadata(
561+
self.create_metadata(
554562
lambda instance=default: instance,
555563
threadsafe=threadsafe,
556564
)
@@ -681,13 +689,6 @@ def dispatch(self, event: Event) -> Iterator[None]:
681689
finally:
682690
self.__debug(event)
683691

684-
def _metadata[**P, T](
685-
self,
686-
wrapped: Callable[P, T],
687-
threadsafe: bool | None = None,
688-
) -> InjectMetadata[P, T]:
689-
return InjectMetadata(wrapped, threadsafe).listen(self)
690-
691692
def _iter_locators(self) -> Iterator[Locator]:
692693
for module in self.__modules:
693694
yield from module._iter_locators()

injection/testing/__init__.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ from injection.loaders import LoadedProfile, ProfileLoader
55

66
TEST_PROFILE_NAME: Final[str] = ...
77

8-
__MODULE: Final[Module] = ...
8+
_test_module: Final[Module] = ...
99

10-
reserve_scoped_test_slot = __MODULE.reserve_scoped_slot
11-
set_test_constant = __MODULE.set_constant
12-
should_be_test_injectable = __MODULE.should_be_injectable
13-
test_constant = __MODULE.constant
14-
test_injectable = __MODULE.injectable
15-
test_scoped = __MODULE.scoped
16-
test_singleton = __MODULE.singleton
10+
reserve_scoped_test_slot = _test_module.reserve_scoped_slot
11+
set_test_constant = _test_module.set_constant
12+
should_be_test_injectable = _test_module.should_be_injectable
13+
test_constant = _test_module.constant
14+
test_injectable = _test_module.injectable
15+
test_scoped = _test_module.scoped
16+
test_singleton = _test_module.singleton
1717

1818
def load_test_profile(loader: ProfileLoader = ...) -> LoadedProfile:
1919
"""

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)