anydi 0.48.1__py3-none-any.whl → 0.50.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
anydi/_async.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import functools
2
+ from collections.abc import Callable
2
3
  from types import TracebackType
3
- from typing import Any, Callable, TypeVar
4
+ from typing import Any, TypeVar
4
5
 
5
6
  import anyio.to_thread
6
7
  from typing_extensions import ParamSpec, Self
anydi/_container.py CHANGED
@@ -9,11 +9,11 @@ import logging
9
9
  import types
10
10
  import uuid
11
11
  from collections import defaultdict
12
- from collections.abc import AsyncIterator, Iterable, Iterator
12
+ from collections.abc import AsyncIterator, Callable, Iterable, Iterator
13
13
  from contextvars import ContextVar
14
- from typing import Annotated, Any, Callable, TypeVar, cast, overload
14
+ from typing import Annotated, Any, TypeVar, cast, get_args, get_origin, overload
15
15
 
16
- from typing_extensions import ParamSpec, Self, get_args, get_origin
16
+ from typing_extensions import ParamSpec, Self, type_repr
17
17
 
18
18
  from ._async import run_sync
19
19
  from ._context import InstanceContext
@@ -33,7 +33,6 @@ from ._typing import (
33
33
  is_inject_marker,
34
34
  is_iterator_type,
35
35
  is_none_type,
36
- type_repr,
37
36
  )
38
37
 
39
38
  T = TypeVar("T", bound=Any)
@@ -808,7 +807,10 @@ class Container:
808
807
  marker = metadata[-1]
809
808
  new_metadata = metadata[:-1]
810
809
  if new_metadata:
811
- new_annotation = Annotated.__class_getitem__((origin, *new_metadata)) # type: ignore
810
+ if hasattr(Annotated, "__getitem__"):
811
+ new_annotation = Annotated.__getitem__((origin, *new_metadata)) # type: ignore
812
+ else:
813
+ new_annotation = Annotated.__class_getitem__((origin, *new_metadata)) # type: ignore
812
814
  else:
813
815
  new_annotation = origin
814
816
  return parameter.replace(annotation=new_annotation, default=marker)
@@ -831,8 +833,7 @@ class Container:
831
833
  # Set inject marker interface
832
834
  parameter.default.interface = interface
833
835
 
834
- # TODO: temporary disable until strict is enforced (remove False)
835
- if False and not self.has_provider_for(interface):
836
+ if not self.has_provider_for(interface):
836
837
  raise LookupError(
837
838
  f"`{type_repr(call)}` has an unknown dependency parameter "
838
839
  f"`{parameter.name}` with an annotation of "
anydi/_decorators.py CHANGED
@@ -1,8 +1,7 @@
1
- from collections.abc import Iterable
1
+ from collections.abc import Callable, Iterable
2
2
  from typing import (
3
3
  TYPE_CHECKING,
4
4
  Any,
5
- Callable,
6
5
  Concatenate,
7
6
  ParamSpec,
8
7
  Protocol,
anydi/_module.py CHANGED
@@ -2,7 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  import importlib
4
4
  import inspect
5
- from typing import TYPE_CHECKING, Any, Callable
5
+ from collections.abc import Callable
6
+ from typing import TYPE_CHECKING, Any
6
7
 
7
8
  from ._decorators import ProviderMetadata, is_provider
8
9
 
anydi/_provider.py CHANGED
@@ -2,9 +2,10 @@ from __future__ import annotations
2
2
 
3
3
  import enum
4
4
  import inspect
5
+ from collections.abc import Callable
5
6
  from dataclasses import dataclass
6
7
  from functools import cached_property
7
- from typing import Any, Callable, NamedTuple
8
+ from typing import Any, NamedTuple
8
9
 
9
10
  from ._scope import Scope
10
11
  from ._typing import NOT_SET
anydi/_scan.py CHANGED
@@ -3,10 +3,10 @@ from __future__ import annotations
3
3
  import importlib
4
4
  import inspect
5
5
  import pkgutil
6
- from collections.abc import Iterable
6
+ from collections.abc import Callable, Iterable
7
7
  from dataclasses import dataclass
8
8
  from types import ModuleType
9
- from typing import TYPE_CHECKING, Any, Callable, Union
9
+ from typing import TYPE_CHECKING, Any
10
10
 
11
11
  from ._decorators import is_injectable
12
12
  from ._typing import get_typed_parameters, is_inject_marker
@@ -14,8 +14,8 @@ from ._typing import get_typed_parameters, is_inject_marker
14
14
  if TYPE_CHECKING:
15
15
  from ._container import Container
16
16
 
17
- Package = Union[ModuleType, str]
18
- PackageOrIterable = Union[Package, Iterable[Package]]
17
+ Package = ModuleType | str
18
+ PackageOrIterable = Package | Iterable[Package]
19
19
 
20
20
 
21
21
  @dataclass(kw_only=True)
anydi/_typing.py CHANGED
@@ -3,44 +3,9 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import inspect
6
- import re
7
- import sys
8
- from collections.abc import AsyncIterator, Iterator
9
- from typing import Any, Callable, ForwardRef, TypeVar
10
-
11
- from typing_extensions import get_args, get_origin
12
-
13
- try:
14
- from types import NoneType
15
- except ImportError:
16
- NoneType = type(None)
17
-
18
-
19
- T = TypeVar("T")
20
-
21
-
22
- def type_repr(obj: Any) -> str:
23
- """Get a string representation of a type or object."""
24
- if isinstance(obj, str):
25
- return obj
26
-
27
- # Get module and qualname with defaults to handle non-types directly
28
- module = getattr(obj, "__module__", type(obj).__module__)
29
- qualname = getattr(obj, "__qualname__", type(obj).__qualname__)
30
-
31
- origin = get_origin(obj)
32
- # If origin exists, handle generics recursively
33
- if origin:
34
- args = ", ".join(type_repr(arg) for arg in get_args(obj))
35
- return f"{type_repr(origin)}[{args}]"
36
-
37
- # Substitute standard library prefixes for clarity
38
- full_qualname = f"{module}.{qualname}"
39
- return re.sub(
40
- r"\b(builtins|typing|typing_extensions|collections\.abc|types)\.",
41
- "",
42
- full_qualname,
43
- )
6
+ from collections.abc import AsyncIterator, Callable, Iterator
7
+ from types import NoneType
8
+ from typing import Any, ForwardRef
44
9
 
45
10
 
46
11
  def is_context_manager(obj: Any) -> bool:
@@ -68,11 +33,8 @@ def get_typed_annotation(
68
33
  ) -> Any:
69
34
  """Get the typed annotation of a callable object."""
70
35
  if isinstance(annotation, str):
71
- if sys.version_info >= (3, 10):
72
- ref = ForwardRef(annotation, module=module)
73
- else:
74
- ref = ForwardRef(annotation)
75
- annotation = ref._evaluate(globalns, globalns, recursive_guard=frozenset()) # noqa
36
+ ref = ForwardRef(annotation, module=module)
37
+ annotation = ref._evaluate(globalns, globalns, recursive_guard=frozenset()) # type: ignore[reportDeprecated]
76
38
  return annotation
77
39
 
78
40
 
anydi/ext/django/apps.py CHANGED
@@ -1,7 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import types
4
- from typing import Callable, cast
4
+ from collections.abc import Callable
5
+ from typing import cast
5
6
 
6
7
  from django.apps import AppConfig
7
8
  from django.conf import settings
@@ -1,4 +1,5 @@
1
- from typing import Any, Callable
1
+ from collections.abc import Callable
2
+ from typing import Any
2
3
 
3
4
  from asgiref.sync import iscoroutinefunction
4
5
  from django.http import HttpRequest
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections.abc import Iterable
4
- from typing import Annotated, Any, Callable
3
+ from collections.abc import Callable, Iterable
4
+ from typing import Annotated, Any
5
5
 
6
6
  from pydantic.fields import ComputedFieldInfo, FieldInfo # noqa
7
7
  from pydantic_settings import BaseSettings
@@ -2,8 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  import inspect
4
4
  import logging
5
- from collections.abc import Iterator
6
- from typing import Any, Callable, cast
5
+ from collections.abc import Callable, Iterator
6
+ from typing import Any, cast
7
7
 
8
8
  import pytest
9
9
  from anyio.pytest_plugin import extract_backend_and_options, get_runner
anydi/testing.py CHANGED
@@ -5,14 +5,13 @@ from collections.abc import Iterable, Iterator, Sequence
5
5
  from typing import Any, TypeVar
6
6
 
7
7
  import wrapt # type: ignore
8
- from typing_extensions import Self
8
+ from typing_extensions import Self, type_repr
9
9
 
10
10
  from ._container import Container
11
11
  from ._context import InstanceContext
12
12
  from ._module import ModuleDef
13
13
  from ._provider import Provider, ProviderDef
14
14
  from ._scope import Scope
15
- from ._typing import type_repr
16
15
 
17
16
  T = TypeVar("T")
18
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anydi
3
- Version: 0.48.1
3
+ Version: 0.50.0
4
4
  Summary: Dependency Injection library
5
5
  Keywords: dependency injection,dependencies,di,async,asyncio,application
6
6
  Author: Anton Ruhlov
@@ -20,16 +20,16 @@ Classifier: Environment :: Web Environment
20
20
  Classifier: Intended Audience :: Developers
21
21
  Classifier: License :: OSI Approved :: MIT License
22
22
  Classifier: Programming Language :: Python :: 3
23
- Classifier: Programming Language :: Python :: 3.9
24
23
  Classifier: Programming Language :: Python :: 3.10
25
24
  Classifier: Programming Language :: Python :: 3.11
26
25
  Classifier: Programming Language :: Python :: 3.12
27
26
  Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Programming Language :: Python :: 3.14
28
28
  Classifier: Programming Language :: Python :: 3 :: Only
29
29
  Requires-Dist: typing-extensions>=4.15.0,<5
30
30
  Requires-Dist: anyio>=3.7.1
31
31
  Requires-Dist: wrapt>=1.17.0,<2
32
- Requires-Python: ~=3.9
32
+ Requires-Python: >=3.10.0, <3.15
33
33
  Project-URL: Repository, https://github.com/antonrh/anydi
34
34
  Description-Content-Type: text/markdown
35
35
 
@@ -58,7 +58,7 @@ http://anydi.readthedocs.io/
58
58
 
59
59
  ---
60
60
 
61
- `AnyDI` is a modern, lightweight Dependency Injection library suitable for any synchronous or asynchronous applications with Python 3.9+, based on type annotations ([PEP 484](https://peps.python.org/pep-0484/)).
61
+ `AnyDI` is a modern, lightweight Dependency Injection library suitable for any synchronous or asynchronous applications with Python 3.10+, based on type annotations ([PEP 484](https://peps.python.org/pep-0484/)).
62
62
 
63
63
  The key features are:
64
64
 
@@ -1,32 +1,32 @@
1
1
  anydi/__init__.py,sha256=KjjYm-1yAFxiPYaMs1WRJMtxE0q_vdX7ZRLQR1fFGs8,567
2
- anydi/_async.py,sha256=KhRd3RmZFcwNDzrMm8ctA1gwrg-6m_7laECTYsZdF5k,1445
3
- anydi/_container.py,sha256=fELFvxMrsrO2MQhAtnMmLKFxkvsaySx5ZwFGHy5KcOw,31860
2
+ anydi/_async.py,sha256=lrKTrqMC81POFbea3kaC9KkY3sp0DaenuVPvwOg88xA,1472
3
+ anydi/_container.py,sha256=t-5BcjsuKnaJ8Wmk9ZXXQN90NQhrVl41bLjObG0wYTY,31940
4
4
  anydi/_context.py,sha256=_Xy8cTpRskb4cxTd-Fe-5NnIZyBe1DnovkofhdeUfmw,3020
5
- anydi/_decorators.py,sha256=F3yBeGQSz1EsulZaEvYn3cd6FEjJRMoyA6u1QCbEwcs,2813
6
- anydi/_module.py,sha256=QPvP27JndZkwl-FYUZWscJm6yfkNzjwoFGURyDhb6Pc,2582
7
- anydi/_provider.py,sha256=ig2ecn-STmFGcpkLE5A5OM35XHtU2NsxFVrGp2CvuvM,2123
8
- anydi/_scan.py,sha256=nOpspmceVucdwf8nUv1QVFsz2sRVWCVUb0QTH9EbWr4,3653
5
+ anydi/_decorators.py,sha256=yxY876_2fzC30UIb4-4mR-J5ToQN3BH61E2cFH-iX8Y,2809
6
+ anydi/_module.py,sha256=2kN5uEXLd2Dsc58gz5IWK43wJewr_QgIVGSO3iWp798,2609
7
+ anydi/_provider.py,sha256=BWW4nXJ5r-0tCgS91kLWzYbrGv1v1oIm8BSt1cyYkDc,2150
8
+ anydi/_scan.py,sha256=SoB9uugaZVqBIW2IMKQGbu9YGaWHT3BhKWrDpiQaINE,3634
9
9
  anydi/_scope.py,sha256=PFHjPb2-n0vhRo9mvD_craTFfoJBzR3y-N3_0apL5Q0,258
10
- anydi/_typing.py,sha256=cYsEnv_QpI8B1DIZ8zPZwywEmZjtx0otJjj6vTLLk_E,3895
10
+ anydi/_typing.py,sha256=LXOmWua-UimL9te8Ye3u3MCLiA7EzNhDuacw4kgnxP4,2877
11
11
  anydi/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  anydi/ext/django/__init__.py,sha256=QI1IABCVgSDTUoh7M9WMECKXwB3xvh04HfQ9TOWw1Mk,223
13
13
  anydi/ext/django/_container.py,sha256=cxVoYQG16WP0S_Yv4TnLwuaaT7NVEOhLWO-YdALJUb4,418
14
14
  anydi/ext/django/_settings.py,sha256=NsYbFBeslqw_tcXCn2b2gKnSp7eb64DM4dRc4tn_eiw,808
15
15
  anydi/ext/django/_utils.py,sha256=sYfUgBV9azddWYB4vNaZadDXcv_MiU-wSfVKV-TZDrE,2695
16
- anydi/ext/django/apps.py,sha256=kGqTUZK55OPtaG5lktavSr88_quDm9GNFUE94eQh6zQ,2965
17
- anydi/ext/django/middleware.py,sha256=5OUdp0OWRozyW338Sq04BDhacaFlyUTTOduS_7EwCTA,854
16
+ anydi/ext/django/apps.py,sha256=vlsufhXRQbQOBWBTVOKJT3X2lCUWKWTVIKxqoZUVeps,2992
17
+ anydi/ext/django/middleware.py,sha256=dL__Ff6fCK0GzIcncsVC3px8JCszSk-wSq5x2hiNM5s,881
18
18
  anydi/ext/django/ninja/__init__.py,sha256=4J0zoHPK9itbTVrjjvLX6Ftrsb2ND8bITqNDIJzEhks,520
19
19
  anydi/ext/django/ninja/_operation.py,sha256=wk5EOjLY3KVIHk9jMCGsFsja9-dQmMOpLpHXciqxQdk,2680
20
20
  anydi/ext/django/ninja/_signature.py,sha256=p7JtyMdFhX4fWQOvAhvZNss6iURNERcdsTsQADTHkMY,2358
21
21
  anydi/ext/fastapi.py,sha256=L9VGPHGy23se1sflmJqTE7LNfQuElVdYEogoT1f5-4A,2324
22
22
  anydi/ext/faststream.py,sha256=Dy81Vf34CP6pEIbZ-41vh_-Dn6Qc-rcf14U5poebjxI,1905
23
- anydi/ext/pydantic_settings.py,sha256=8IXXLuG_OvKbvKlBkBRQUHcXgbTpgQUxeWyoMcRIUQM,1488
24
- anydi/ext/pytest_plugin.py,sha256=IoP6XKuGLGLd2Xlpfttc3mI4pxCm2WQLE7x_a7asbv4,4732
23
+ anydi/ext/pydantic_settings.py,sha256=0GQjw7QpQlT5p6GxFClXYdtc6J42PClmAnRWPEzMjvY,1488
24
+ anydi/ext/pytest_plugin.py,sha256=yqaFPzYD88HEmqc2URsBtp2FUktORhUxWfs0hJja1IU,4732
25
25
  anydi/ext/starlette/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  anydi/ext/starlette/middleware.py,sha256=MxnzshAs-CMvjJp0r457k52MzBL8O4KAuClnF6exBdU,803
27
27
  anydi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- anydi/testing.py,sha256=waz0nO-MnfPGQLnPuDT0bdEdfqfmgkbsuFuxWfct6kw,5539
29
- anydi-0.48.1.dist-info/WHEEL,sha256=Pi5uDq5Fdo_Rr-HD5h9BiPn9Et29Y9Sh8NhcJNnFU1c,79
30
- anydi-0.48.1.dist-info/entry_points.txt,sha256=AgOcQYM5KyS4D37QcYb00tiid0QA-pD1VrjHHq4QAps,44
31
- anydi-0.48.1.dist-info/METADATA,sha256=X9swcb7pHvqntskN44YfhEJlCnR6wCGJWGwARHAPWfM,4956
32
- anydi-0.48.1.dist-info/RECORD,,
28
+ anydi/testing.py,sha256=gbQnJ6qFaQ5qbUwFWfSJ67SKhxLuPzwLGidistsmHk8,5519
29
+ anydi-0.50.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
30
+ anydi-0.50.0.dist-info/entry_points.txt,sha256=AgOcQYM5KyS4D37QcYb00tiid0QA-pD1VrjHHq4QAps,44
31
+ anydi-0.50.0.dist-info/METADATA,sha256=sYMf1a1xJfwEzJjGYDrVFT0sVEi_80XVRtb_JwrQF0Y,4968
32
+ anydi-0.50.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.8.17
2
+ Generator: uv 0.8.24
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any