Merge branch 'release/4.43.0' into master

This commit is contained in:
Roman Mogylatov 2024-11-04 00:03:25 -05:00
commit abf2a2577c
17 changed files with 221744 additions and 161996 deletions

View File

@ -15,11 +15,11 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.13
- run: pip install tox - run: pip install tox
- run: tox - run: tox
env: env:
TOXENV: 3.12 TOXENV: 3.13
linters: linters:
name: Run linters name: Run linters
@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.13
- run: pip install tox - run: pip install tox
- run: tox - run: tox
env: env:
@ -45,7 +45,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.13
- run: | - run: |
python -m pip install --upgrade pip setuptools python -m pip install --upgrade pip setuptools
python setup.py sdist python setup.py sdist
@ -61,7 +61,7 @@ jobs:
matrix: matrix:
os: [ubuntu-22.04, windows-2019, macos-14] os: [ubuntu-22.04, windows-2019, macos-14]
env: env:
CIBW_SKIP: cp27-* cp313-* CIBW_SKIP: cp27-*
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Build wheels - name: Build wheels
@ -75,7 +75,7 @@ jobs:
needs: [tests, linters] needs: [tests, linters]
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
env: env:
CIBW_SKIP: cp27-* cp313-* CIBW_SKIP: cp27-*
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
@ -114,7 +114,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.13
- run: pip install awscli - run: pip install awscli
- run: pip install -r requirements-doc.txt - run: pip install -r requirements-doc.txt
- run: pip install -e . - run: pip install -e .

View File

@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12] python-version: [3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
@ -40,8 +40,8 @@ jobs:
name: Run tests with coverage name: Run tests with coverage
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
# Cython's version <3 issue with tracing: "error: no member named 'use_tracing' in 'struct _PyCFrame'" DEPENDENCY_INJECTOR_DEBUG_MODE: 1
# DEPENDENCY_INJECTOR_DEBUG_MODE: 1 PIP_VERBOSE: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
@ -49,9 +49,9 @@ jobs:
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.12
- run: pip install tox cython==0.29.37 - run: pip install tox 'cython>=3,<4'
- run: make cythonize - run: make cythonize
- run: tox - run: tox -vv
env: env:
TOXENV: coveralls TOXENV: coveralls
@ -65,7 +65,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.12 python-version: 3.13
- run: pip install tox - run: pip install tox
- run: tox - run: tox
env: env:

View File

@ -21,3 +21,4 @@ Dependency Injector Contributors
+ Thiago Hiromi (thiromi) + Thiago Hiromi (thiromi)
+ Felipe Rubio (krouw) + Felipe Rubio (krouw)
+ Anton Petrov (anton-petrov) + Anton Petrov (anton-petrov)
+ ZipFile (ZipFile)

View File

@ -2,7 +2,7 @@ VERSION := $(shell python setup.py --version)
CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx') CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx')
CYTHON_DIRECTIVES = -Xlanguage_level=2 CYTHON_DIRECTIVES = -Xlanguage_level=3
ifdef DEPENDENCY_INJECTOR_DEBUG_MODE ifdef DEPENDENCY_INJECTOR_DEBUG_MODE
CYTHON_DIRECTIVES += -Xprofile=True CYTHON_DIRECTIVES += -Xprofile=True

View File

@ -7,6 +7,12 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_ follows `Semantic versioning`_
4.43.0
--------
- Add support for Python 3.13.
- Migrate to Cython 3 (version 3.0.11). Many thanks to `ZipFile <https://github.com/ZipFile>`_ for
this contribution `#813 <https://github.com/ets-labs/python-dependency-injector/pull/813>`_.
4.42.0 4.42.0
-------- --------
- Promote release ``4.42.0b1`` to a production release. - Promote release ``4.42.0b1`` to a production release.

View File

@ -1,4 +1,5 @@
cython==0.29.37 cython==3.0.11
setuptools
pytest pytest
pytest-asyncio pytest-asyncio
tox tox

View File

@ -1,3 +1,3 @@
flask==2.1.3 flask==2.1.3
werkzeug==2.2.2 werkzeug==2.2.2
aiohttp==3.9.0b1 aiohttp

View File

@ -111,6 +111,7 @@ setup(name="dependency-injector",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: PyPy",
"Framework :: AsyncIO", "Framework :: AsyncIO",

View File

@ -1,6 +1,6 @@
"""Top-level package.""" """Top-level package."""
__version__ = "4.42.0" __version__ = "4.43.0"
"""Version number. """Version number.
:type: str :type: str

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -20,10 +20,10 @@ cdef tuple __COROUTINE_TYPES
# Base providers # Base providers
cdef class Provider(object): cdef class Provider(object):
cdef tuple __overridden cdef tuple _overridden
cdef Provider __last_overriding cdef Provider _last_overriding
cdef tuple __overrides cdef tuple _overrides
cdef int __async_mode cdef int _async_mode
cpdef bint is_async_mode_enabled(self) cpdef bint is_async_mode_enabled(self)
cpdef bint is_async_mode_disabled(self) cpdef bint is_async_mode_disabled(self)
@ -34,32 +34,32 @@ cdef class Provider(object):
cdef class Object(Provider): cdef class Object(Provider):
cdef object __provides cdef object _provides
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Self(Provider): cdef class Self(Provider):
cdef object __container cdef object _container
cdef tuple __alt_names cdef tuple _alt_names
cdef class Delegate(Provider): cdef class Delegate(Provider):
cdef object __provides cdef object _provides
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Aggregate(Provider): cdef class Aggregate(Provider):
cdef dict __providers cdef dict _providers
cdef Provider __get_provider(self, object provider_name) cdef Provider __get_provider(self, object provider_name)
cdef class Dependency(Provider): cdef class Dependency(Provider):
cdef object __instance_of cdef object _instance_of
cdef object __default cdef object _default
cdef object __parent cdef object _parent
cdef class ExternalDependency(Dependency): cdef class ExternalDependency(Dependency):
@ -67,21 +67,21 @@ cdef class ExternalDependency(Dependency):
cdef class DependenciesContainer(Object): cdef class DependenciesContainer(Object):
cdef dict __providers cdef dict _providers
cdef object __parent cdef object _parent
cpdef object _override_providers(self, object container) cpdef object _override_providers(self, object container)
# Callable providers # Callable providers
cdef class Callable(Provider): cdef class Callable(Provider):
cdef object __provides cdef object _provides
cdef tuple __args cdef tuple _args
cdef int __args_len cdef int _args_len
cdef tuple __kwargs cdef tuple _kwargs
cdef int __kwargs_len cdef int _kwargs_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
@ -117,11 +117,11 @@ cdef class CoroutineDelegate(Delegate):
# Configuration providers # Configuration providers
cdef class ConfigurationOption(Provider): cdef class ConfigurationOption(Provider):
cdef tuple __name cdef tuple _name
cdef Configuration __root cdef Configuration _root
cdef dict __children cdef dict _children
cdef bint __required cdef bint _required
cdef object __cache cdef object _cache
cdef class TypedConfigurationOption(Callable): cdef class TypedConfigurationOption(Callable):
@ -129,22 +129,22 @@ cdef class TypedConfigurationOption(Callable):
cdef class Configuration(Object): cdef class Configuration(Object):
cdef str __name cdef str _name
cdef bint __strict cdef bint __strict
cdef dict __children cdef dict _children
cdef list __ini_files cdef list _ini_files
cdef list __yaml_files cdef list _yaml_files
cdef list __json_files cdef list _json_files
cdef list __pydantic_settings cdef list _pydantic_settings
cdef object __weakref__ cdef object __weakref__
# Factory providers # Factory providers
cdef class Factory(Provider): cdef class Factory(Provider):
cdef Callable __instantiator cdef Callable _instantiator
cdef tuple __attributes cdef tuple _attributes
cdef int __attributes_len cdef int _attributes_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
@ -167,8 +167,8 @@ cdef class FactoryAggregate(Aggregate):
# Singleton providers # Singleton providers
cdef class BaseSingleton(Provider): cdef class BaseSingleton(Provider):
cdef Factory __instantiator cdef Factory _instantiator
cdef object __storage cdef object _storage
cdef class Singleton(BaseSingleton): cdef class Singleton(BaseSingleton):
@ -181,7 +181,7 @@ cdef class DelegatedSingleton(Singleton):
cdef class ThreadSafeSingleton(BaseSingleton): cdef class ThreadSafeSingleton(BaseSingleton):
cdef object __storage_lock cdef object _storage_lock
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
@ -215,87 +215,87 @@ cdef class SingletonDelegate(Delegate):
# Miscellaneous providers # Miscellaneous providers
cdef class List(Provider): cdef class List(Provider):
cdef tuple __args cdef tuple _args
cdef int __args_len cdef int _args_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Dict(Provider): cdef class Dict(Provider):
cdef tuple __kwargs cdef tuple _kwargs
cdef int __kwargs_len cdef int _kwargs_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Resource(Provider): cdef class Resource(Provider):
cdef object __provides cdef object _provides
cdef bint __initialized cdef bint _initialized
cdef object __shutdowner cdef object _shutdowner
cdef object __resource cdef object _resource
cdef tuple __args cdef tuple _args
cdef int __args_len cdef int _args_len
cdef tuple __kwargs cdef tuple _kwargs
cdef int __kwargs_len cdef int _kwargs_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Container(Provider): cdef class Container(Provider):
cdef object __container_cls cdef object _container_cls
cdef dict __overriding_providers cdef dict _overriding_providers
cdef object __container cdef object _container
cdef object __parent cdef object _parent
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class Selector(Provider): cdef class Selector(Provider):
cdef object __selector cdef object _selector
cdef dict __providers cdef dict _providers
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
# Provided instance # Provided instance
cdef class ProvidedInstance(Provider): cdef class ProvidedInstance(Provider):
cdef object __provides cdef object _provides
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class AttributeGetter(Provider): cdef class AttributeGetter(Provider):
cdef object __provides cdef object _provides
cdef object __name cdef object _name
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class ItemGetter(Provider): cdef class ItemGetter(Provider):
cdef object __provides cdef object _provides
cdef object __name cdef object _name
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
cdef class MethodCaller(Provider): cdef class MethodCaller(Provider):
cdef object __provides cdef object _provides
cdef tuple __args cdef tuple _args
cdef int __args_len cdef int _args_len
cdef tuple __kwargs cdef tuple _kwargs
cdef int __kwargs_len cdef int _kwargs_len
cpdef object _provide(self, tuple args, dict kwargs) cpdef object _provide(self, tuple args, dict kwargs)
# Injections # Injections
cdef class Injection(object): cdef class Injection(object):
cdef object __value cdef object _value
cdef int __is_provider cdef int _is_provider
cdef int __is_delegated cdef int _is_delegated
cdef int __call cdef int _call
cdef class PositionalInjection(Injection): cdef class PositionalInjection(Injection):
@ -303,7 +303,7 @@ cdef class PositionalInjection(Injection):
cdef class NamedInjection(Injection): cdef class NamedInjection(Injection):
cdef object __name cdef object _name
cpdef tuple parse_positional_injections(tuple args) cpdef tuple parse_positional_injections(tuple args)
@ -314,12 +314,12 @@ cpdef tuple parse_named_injections(dict kwargs)
# Utils # Utils
cdef class OverridingContext(object): cdef class OverridingContext(object):
cdef Provider __overridden cdef Provider _overridden
cdef Provider __overriding cdef Provider _overriding
cdef class BaseSingletonResetContext(object): cdef class BaseSingletonResetContext(object):
cdef object __singleton cdef object _singleton
cdef class SingletonResetContext(BaseSingletonResetContext): cdef class SingletonResetContext(BaseSingletonResetContext):
@ -356,19 +356,19 @@ cpdef object deepcopy(object instance, dict memo=*)
# Inline helper functions # Inline helper functions
cdef inline object __get_name(NamedInjection self): cdef inline object __get_name(NamedInjection self):
return self.__name return self._name
cdef inline object __get_value(Injection self): cdef inline object __get_value(Injection self):
if self.__call == 0: if self._call == 0:
return self.__value return self._value
return self.__value() return self._value()
cdef inline object __get_value_kwargs(Injection self, dict kwargs): cdef inline object __get_value_kwargs(Injection self, dict kwargs):
if self.__call == 0: if self._call == 0:
return self.__value return self._value
return self.__value(**kwargs) return self._value(**kwargs)
cdef inline tuple __separate_prefixed_kwargs(dict kwargs): cdef inline tuple __separate_prefixed_kwargs(dict kwargs):
@ -633,14 +633,14 @@ cdef inline object __async_result_callback(object future_result, object future):
cdef inline object __callable_call(Callable self, tuple args, dict kwargs, ): cdef inline object __callable_call(Callable self, tuple args, dict kwargs, ):
return __call( return __call(
self.__provides, self._provides,
args, args,
self.__args, self._args,
self.__args_len, self._args_len,
kwargs, kwargs,
self.__kwargs, self._kwargs,
self.__kwargs_len, self._kwargs_len,
self.__async_mode, self._async_mode,
) )
@ -648,18 +648,18 @@ cdef inline object __factory_call(Factory self, tuple args, dict kwargs):
cdef object instance cdef object instance
instance = __call( instance = __call(
self.__instantiator.__provides, self._instantiator._provides,
args, args,
self.__instantiator.__args, self._instantiator._args,
self.__instantiator.__args_len, self._instantiator._args_len,
kwargs, kwargs,
self.__instantiator.__kwargs, self._instantiator._kwargs,
self.__instantiator.__kwargs_len, self._instantiator._kwargs_len,
self.__async_mode, self._async_mode,
) )
if self.__attributes_len > 0: if self._attributes_len > 0:
attributes = __provide_attributes(self.__attributes, self.__attributes_len) attributes = __provide_attributes(self._attributes, self._attributes_len)
is_future_instance = __is_future_or_coroutine(instance) is_future_instance = __is_future_or_coroutine(instance)
is_future_attributes = __is_future_or_coroutine(attributes) is_future_attributes = __is_future_or_coroutine(attributes)

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ from aiohttp import web, test_utils
from dependency_injector import containers, providers from dependency_injector import containers, providers
from dependency_injector.ext import aiohttp from dependency_injector.ext import aiohttp
from pytest import fixture, mark from pytest import fixture, mark
from pytest_asyncio import fixture as aio_fixture
async def index_view(_): async def index_view(_):
@ -63,7 +64,7 @@ def app():
return app return app
@fixture @aio_fixture
async def client(app): async def client(app):
async with test_utils.TestClient(test_utils.TestServer(app)) as client: async with test_utils.TestClient(test_utils.TestServer(app)) as client:
yield client yield client

View File

@ -1,5 +1,6 @@
from httpx import AsyncClient from httpx import AsyncClient
from pytest import fixture, mark from pytest import fixture, mark
from pytest_asyncio import fixture as aio_fixture
# Runtime import to avoid syntax errors in samples on Python < 3.5 and reach top-dir # Runtime import to avoid syntax errors in samples on Python < 3.5 and reach top-dir
import os import os
@ -16,7 +17,7 @@ sys.path.append(_SAMPLES_DIR)
from wiringfastapi import web from wiringfastapi import web
@fixture @aio_fixture
async def async_client(): async def async_client():
client = AsyncClient(app=web.app, base_url="http://test") client = AsyncClient(app=web.app, base_url="http://test")
yield client yield client

13
tox.ini
View File

@ -1,6 +1,7 @@
[tox] [tox]
parallel_show_output = true
envlist= envlist=
coveralls, pylint, flake8, pydocstyle, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, pypy3.9, pypy3.10 coveralls, pylint, flake8, pydocstyle, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, pypy3.9, pypy3.10
[testenv] [testenv]
deps= deps=
@ -24,13 +25,13 @@ commands = pytest -c tests/.configs/pytest.ini
python_files = test_*_py3*.py python_files = test_*_py3*.py
[testenv:coveralls] [testenv:coveralls]
passenv = GITHUB_*, COVERALLS_* passenv = GITHUB_*, COVERALLS_*, DEPENDENCY_INJECTOR_*
basepython=python3.12 basepython=python3.12 # TODO: Upgrade to version 3.13 is blocked by coveralls 4.0.1 not supporting Python 3.13
deps= deps=
{[testenv]deps} {[testenv]deps}
cython<3.0 cython>=3,<4
coverage coverage>=7
coveralls coveralls>=4
commands= commands=
coverage erase coverage erase
coverage run --rcfile=./.coveragerc -m pytest -c tests/.configs/pytest.ini coverage run --rcfile=./.coveragerc -m pytest -c tests/.configs/pytest.ini