mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Merge branch 'release/4.41.0' into master
This commit is contained in:
commit
cc2304e46e
76
.github/workflows/publishing.yml
vendored
76
.github/workflows/publishing.yml
vendored
|
@ -1,6 +1,7 @@
|
||||||
name: Publishing
|
name: Publishing
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
|
@ -9,28 +10,28 @@ jobs:
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: pip install tox
|
- run: pip install tox
|
||||||
- run: tox
|
- run: tox
|
||||||
env:
|
env:
|
||||||
TOXENV: "3.10"
|
TOXENV: 3.11
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
name: Run linters
|
name: Run linters
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
toxenv: [flake8, pydocstyle, mypy, pylint]
|
toxenv: [flake8, pydocstyle, mypy, pylint]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: pip install tox
|
- run: pip install tox
|
||||||
- run: tox
|
- run: tox
|
||||||
env:
|
env:
|
||||||
|
@ -39,14 +40,14 @@ jobs:
|
||||||
build-sdist:
|
build-sdist:
|
||||||
name: Build source tarball
|
name: Build source tarball
|
||||||
needs: [tests, linters]
|
needs: [tests, linters]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: python setup.py sdist
|
- run: python setup.py sdist
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ./dist/*
|
path: ./dist/*
|
||||||
|
|
||||||
|
@ -56,47 +57,44 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, windows-2019, macOS-10.15]
|
os: [ubuntu-22.04, windows-2019, macos-11]
|
||||||
env:
|
env:
|
||||||
CIBW_SKIP: cp27-win*
|
CIBW_SKIP: cp27-win*
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- name: Build wheels
|
||||||
with:
|
uses: pypa/cibuildwheel@v2.11.3
|
||||||
python-version: "3.10"
|
- uses: actions/upload-artifact@v3
|
||||||
- run: pip install cibuildwheel==2.1.3
|
|
||||||
- run: cibuildwheel --output-dir wheelhouse
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
with:
|
||||||
path: ./wheelhouse/*.whl
|
path: ./wheelhouse/*.whl
|
||||||
|
|
||||||
build-wheels-linux-aarch64:
|
build-wheels-linux-aarch64:
|
||||||
name: Build wheels (ubuntu-latest-aarch64)
|
name: Build wheels (ubuntu-22.04-aarch64)
|
||||||
needs: [tests, linters]
|
needs: [tests, linters]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
if: runner.os == 'Linux'
|
||||||
- uses: actions/setup-python@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
with:
|
- name: Build wheels
|
||||||
python-version: "3.10"
|
uses: pypa/cibuildwheel@v2.11.3
|
||||||
- run: pip install cibuildwheel==2.1.3
|
env:
|
||||||
- run: cibuildwheel --archs aarch64 --output-dir wheelhouse
|
CIBW_ARCHS_LINUX: aarch64
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ./wheelhouse/*.whl
|
path: ./wheelhouse/*.whl
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Publish on PyPI
|
name: Publish on PyPI
|
||||||
needs: [build-sdist, build-wheels, build-wheels-linux-aarch64]
|
needs: [build-sdist, build-wheels, build-wheels-linux-aarch64]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: artifact
|
name: artifact
|
||||||
path: dist
|
path: dist
|
||||||
- uses: pypa/gh-action-pypi-publish@master
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
with:
|
with:
|
||||||
user: __token__
|
user: __token__
|
||||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
@ -107,12 +105,12 @@ jobs:
|
||||||
publish-docs:
|
publish-docs:
|
||||||
name: Publish docs
|
name: Publish docs
|
||||||
needs: [publish]
|
needs: [publish]
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: pip install -r requirements-doc.txt
|
- run: pip install -r requirements-doc.txt
|
||||||
- run: pip install awscli
|
- run: pip install awscli
|
||||||
- run: pip install -e .
|
- run: pip install -e .
|
||||||
|
|
34
.github/workflows/tests-and-linters.yml
vendored
34
.github/workflows/tests-and-linters.yml
vendored
|
@ -4,15 +4,31 @@ on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
tests-on-legacy-versions:
|
||||||
|
name: Run tests on legacy versions
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [2.7, 3.5, 3.6, 3.7, pypy2.7, pypy3.9]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- run: pip install tox
|
||||||
|
- run: tox
|
||||||
|
env:
|
||||||
|
TOXENV: ${{ matrix.python-version }}
|
||||||
|
|
||||||
test-on-different-versions:
|
test-on-different-versions:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", pypy2, pypy3]
|
python-version: [3.8, 3.9, "3.10", 3.11]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- run: pip install tox
|
- run: pip install tox
|
||||||
|
@ -28,10 +44,10 @@ jobs:
|
||||||
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:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: pip install tox cython
|
- run: pip install tox cython
|
||||||
- run: make cythonize
|
- run: make cythonize
|
||||||
- run: tox
|
- run: tox
|
||||||
|
@ -45,10 +61,10 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
toxenv: [flake8, pydocstyle, mypy, pylint]
|
toxenv: [flake8, pydocstyle, mypy, pylint]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: 3.11
|
||||||
- run: pip install tox
|
- run: pip install tox
|
||||||
- run: tox
|
- run: tox
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
:target: https://pypi.org/project/dependency-injector/
|
:target: https://pypi.org/project/dependency-injector/
|
||||||
:alt: Wheel
|
:alt: Wheel
|
||||||
|
|
||||||
.. image:: https://img.shields.io/github/workflow/status/ets-labs/python-dependency-injector/Tests%20and%20linters/master
|
.. image:: https://img.shields.io/github/actions/workflow/status/ets-labs/python-dependency-injector/tests-and-linters.yml?branch=master
|
||||||
:target: https://github.com/ets-labs/python-dependency-injector/actions
|
:target: https://github.com/ets-labs/python-dependency-injector/actions
|
||||||
:alt: Build Status
|
:alt: Build Status
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ Dependency Injector --- Dependency injection framework for Python
|
||||||
:target: https://pypi.org/project/dependency-injector/
|
:target: https://pypi.org/project/dependency-injector/
|
||||||
:alt: Wheel
|
:alt: Wheel
|
||||||
|
|
||||||
.. image:: https://img.shields.io/github/workflow/status/ets-labs/python-dependency-injector/Tests%20and%20linters/master
|
.. image:: https://img.shields.io/github/actions/workflow/status/ets-labs/python-dependency-injector/tests-and-linters.yml?branch=master
|
||||||
:target: https://github.com/ets-labs/python-dependency-injector/actions
|
:target: https://github.com/ets-labs/python-dependency-injector/actions
|
||||||
:alt: Build Status
|
:alt: Build Status
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,22 @@ 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.41.0
|
||||||
|
------
|
||||||
|
- Add support of Python 3.11.
|
||||||
|
- Allow Closing to detect dependent resources `#633 <https://github.com/ets-labs/python-dependency-injector/issues/633>`_,
|
||||||
|
`#636 <https://github.com/ets-labs/python-dependency-injector/pull/636>`_. Thanks `Jamie Stumme @StummeJ <https://github.com/StummeJ>`_
|
||||||
|
for the contribution.
|
||||||
|
- Update CI/CD to use Ubuntu 22.04.
|
||||||
|
- Update CI/CD to ``actions/checkout@v3``, ``actions/setup-python@v4``, ``actions/upload-artifact@v3``, ``pypa/cibuildwheel@v2.11.3``,
|
||||||
|
and ``actions/download-artifact@v3``.
|
||||||
|
- Fix install crash on non-utf8 systems `#644 <https://github.com/ets-labs/python-dependency-injector/pull/644>`_.
|
||||||
|
- Fix a bug in Windows build with default charset `#635 <https://github.com/ets-labs/python-dependency-injector/pull/635>`_.
|
||||||
|
- Update FastAPI Redis example to use ``aioredis`` version 2 `#613 <https://github.com/ets-labs/python-dependency-injector/pull/613>`_.
|
||||||
|
- Update documentation on creating custom providers `#598 <https://github.com/ets-labs/python-dependency-injector/pull/598>`_.
|
||||||
|
- Regenerate C sources using Cython 0.29.32.
|
||||||
|
- Fix builds badge.
|
||||||
|
|
||||||
4.40.0
|
4.40.0
|
||||||
------
|
------
|
||||||
- Add ``Configuration.from_json()`` method to load configuration from a json file.
|
- Add ``Configuration.from_json()`` method to load configuration from a json file.
|
||||||
|
|
|
@ -16,10 +16,11 @@ To create a custom provider you need to follow these rules:
|
||||||
1. New provider class should inherit :py:class:`Provider`.
|
1. New provider class should inherit :py:class:`Provider`.
|
||||||
2. You need to implement the ``Provider._provide()`` method.
|
2. You need to implement the ``Provider._provide()`` method.
|
||||||
3. You need to implement the ``Provider.__deepcopy__()`` method. It should return an
|
3. You need to implement the ``Provider.__deepcopy__()`` method. It should return an
|
||||||
equivalent copy of a provider. All providers must be copied with a ``deepcopy()`` function
|
equivalent copy of a provider. All providers must be copied with the ``deepcopy()`` function
|
||||||
from the ``providers`` module. After the a new provider object is created use
|
from the ``providers`` module. It's essential to pass ``memo`` into ``deepcopy`` in order to keep
|
||||||
``Provider._copy_overriding()`` method to copy all overriding providers. See the example
|
the preconfigured ``args`` and ``kwargs`` of stored providers. After the a new provider object
|
||||||
below.
|
is created, use ``Provider._copy_overriding()`` method to copy all overriding providers. See the
|
||||||
|
example below.
|
||||||
4. If new provider has a ``__init__()`` method, it should call the parent
|
4. If new provider has a ``__init__()`` method, it should call the parent
|
||||||
``Provider.__init__()``.
|
``Provider.__init__()``.
|
||||||
5. If new provider stores any other providers, these providers should be listed in
|
5. If new provider stores any other providers, these providers should be listed in
|
||||||
|
@ -33,7 +34,7 @@ To create a custom provider you need to follow these rules:
|
||||||
.. note::
|
.. note::
|
||||||
1. Prefer delegation over inheritance. If you choose between inheriting a ``Factory`` or
|
1. Prefer delegation over inheritance. If you choose between inheriting a ``Factory`` or
|
||||||
inheriting a ``Provider`` and use ``Factory`` internally - the last is better.
|
inheriting a ``Provider`` and use ``Factory`` internally - the last is better.
|
||||||
2. When create a new provider follow the ``Factory``-like injections style. Consistency matters.
|
2. When creating a new provider follow the ``Factory``-like injections style. Consistency matters.
|
||||||
3. Use the ``__slots__`` attribute to make sure nothing could be attached to your provider. You
|
3. Use the ``__slots__`` attribute to make sure nothing could be attached to your provider. You
|
||||||
will also save some memory.
|
will also save some memory.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM python:3.9-buster
|
FROM python:3.10-buster
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
|
|
@ -24,35 +24,26 @@ The output should be something like:
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=1, just started
|
fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # Configuration loaded
|
fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # Configuration loaded
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.116 * Running mode=standalone, port=6379.
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * monotonic clock: POSIX clock_gettime
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.116 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * Running mode=standalone, port=6379.
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.116 # Server initialized
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 # Server initialized
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Loading RDB produced by version 6.0.9
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Loading RDB produced by version 7.0.5
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB age 1 seconds
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB age 58 seconds
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB memory usage when created 0.77 Mb
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB memory usage when created 0.85 Mb
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * DB loaded from disk: 0.000 seconds
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Done loading RDB, keys loaded: 0, keys expired: 0.
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Ready to accept connections
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * DB loaded from disk: 0.000 seconds
|
||||||
redis_1 | 1:signal-handler (1609728137) Received SIGTERM scheduling shutdown...
|
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.488 * Ready to accept connections
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # User requested shutdown...
|
fastapi-redis-example-1 | INFO: Started server process [1]
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # Redis is now ready to exit, bye bye...
|
fastapi-redis-example-1 | INFO: Waiting for application startup.
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
|
fastapi-redis-example-1 | INFO: Application startup complete.
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=1, just started
|
fastapi-redis-example-1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
|
||||||
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # Configuration loaded
|
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Running mode=standalone, port=6379.
|
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET /favicon.ico HTTP/1.1" 404 Not Found
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
|
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 # Server initialized
|
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Loading RDB produced by version 6.0.9
|
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * RDB age 9 seconds
|
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * RDB memory usage when created 0.77 Mb
|
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * DB loaded from disk: 0.000 seconds
|
|
||||||
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Ready to accept connections
|
|
||||||
example_1 | INFO: Started server process [1]
|
|
||||||
example_1 | INFO: Waiting for application startup.
|
|
||||||
example_1 | INFO: Application startup complete.
|
|
||||||
example_1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
|
|
||||||
|
|
||||||
Test
|
Test
|
||||||
----
|
----
|
||||||
|
@ -69,9 +60,9 @@ The output should be something like:
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
platform linux -- Python 3.9, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
|
platform linux -- Python 3.10.9, pytest-7.2.0, pluggy-1.0.0
|
||||||
rootdir: /code
|
rootdir: /code
|
||||||
plugins: cov-2.10.1, asyncio-0.14.0
|
plugins: cov-4.0.0, asyncio-0.20.3
|
||||||
collected 1 item
|
collected 1 item
|
||||||
|
|
||||||
fastapiredis/tests.py . [100%]
|
fastapiredis/tests.py . [100%]
|
||||||
|
@ -80,10 +71,10 @@ The output should be something like:
|
||||||
Name Stmts Miss Cover
|
Name Stmts Miss Cover
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
fastapiredis/__init__.py 0 0 100%
|
fastapiredis/__init__.py 0 0 100%
|
||||||
fastapiredis/application.py 15 0 100%
|
fastapiredis/application.py 14 0 100%
|
||||||
fastapiredis/containers.py 6 0 100%
|
fastapiredis/containers.py 6 0 100%
|
||||||
fastapiredis/redis.py 7 4 43%
|
fastapiredis/redis.py 7 4 43%
|
||||||
fastapiredis/services.py 7 3 57%
|
fastapiredis/services.py 7 3 57%
|
||||||
fastapiredis/tests.py 18 0 100%
|
fastapiredis/tests.py 18 0 100%
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
TOTAL 53 7 87%
|
TOTAL 52 7 87%
|
|
@ -1,12 +1,10 @@
|
||||||
"""Redis client module."""
|
|
||||||
|
|
||||||
from typing import AsyncIterator
|
from typing import AsyncIterator
|
||||||
|
|
||||||
from aioredis import create_redis_pool, Redis
|
from aioredis import from_url, Redis
|
||||||
|
|
||||||
|
|
||||||
async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
|
async def init_redis_pool(host: str, password: str) -> AsyncIterator[Redis]:
|
||||||
pool = await create_redis_pool(f"redis://{host}", password=password)
|
session = from_url(f"redis://{host}", password=password, encoding="utf-8", decode_responses=True)
|
||||||
yield pool
|
yield session
|
||||||
pool.close()
|
session.close()
|
||||||
await pool.wait_closed()
|
await session.wait_closed()
|
||||||
|
|
|
@ -9,4 +9,4 @@ class Service:
|
||||||
|
|
||||||
async def process(self) -> str:
|
async def process(self) -> str:
|
||||||
await self._redis.set("my-key", "value")
|
await self._redis.set("my-key", "value")
|
||||||
return await self._redis.get("my-key", encoding="utf-8")
|
return await self._redis.get("my-key")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
dependency-injector
|
dependency-injector
|
||||||
fastapi
|
fastapi
|
||||||
uvicorn
|
uvicorn
|
||||||
aioredis<2 # TODO: Update example to work with aioredis >= 2.0
|
aioredis
|
||||||
|
|
||||||
# For testing:
|
# For testing:
|
||||||
pytest
|
pytest
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cython==0.29.30
|
cython==0.29.32
|
||||||
pytest
|
pytest
|
||||||
pytest-asyncio
|
pytest-asyncio
|
||||||
tox
|
tox
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[flake8]
|
[flake8]
|
||||||
max_line_length = 100
|
max_line_length = 120
|
||||||
max_complexity = 10
|
max_complexity = 10
|
||||||
exclude = types.py
|
exclude = types.py
|
||||||
per-file-ignores =
|
per-file-ignores =
|
||||||
|
|
14
setup.py
14
setup.py
|
@ -2,24 +2,31 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
|
def _open(filename):
|
||||||
|
if sys.version_info[0] == 2:
|
||||||
|
return open(filename)
|
||||||
|
return open(filename, encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
# Defining setup variables:
|
# Defining setup variables:
|
||||||
defined_macros = dict()
|
defined_macros = dict()
|
||||||
defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 0
|
defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 0
|
||||||
|
|
||||||
# Getting description:
|
# Getting description:
|
||||||
with open("README.rst") as readme_file:
|
with _open("README.rst") as readme_file:
|
||||||
description = readme_file.read()
|
description = readme_file.read()
|
||||||
|
|
||||||
# Getting requirements:
|
# Getting requirements:
|
||||||
with open("requirements.txt") as requirements_file:
|
with _open("requirements.txt") as requirements_file:
|
||||||
requirements = requirements_file.readlines()
|
requirements = requirements_file.readlines()
|
||||||
|
|
||||||
# Getting version:
|
# Getting version:
|
||||||
with open("src/dependency_injector/__init__.py") as init_file:
|
with _open("src/dependency_injector/__init__.py") as init_file:
|
||||||
version = re.search("__version__ = \"(.*?)\"", init_file.read()).group(1)
|
version = re.search("__version__ = \"(.*?)\"", init_file.read()).group(1)
|
||||||
|
|
||||||
# Adding debug options:
|
# Adding debug options:
|
||||||
|
@ -106,6 +113,7 @@ setup(name="dependency-injector",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
"Programming Language :: Python :: Implementation :: PyPy",
|
"Programming Language :: Python :: Implementation :: PyPy",
|
||||||
"Framework :: AsyncIO",
|
"Framework :: AsyncIO",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Top-level package."""
|
"""Top-level package."""
|
||||||
|
|
||||||
__version__ = "4.40.0"
|
__version__ = "4.41.0"
|
||||||
"""Version number.
|
"""Version number.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Generated by Cython 0.29.30 */
|
/* Generated by Cython 0.29.32 */
|
||||||
|
|
||||||
#ifndef PY_SSIZE_T_CLEAN
|
#ifndef PY_SSIZE_T_CLEAN
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
||||||
#error Cython requires Python 2.6+ or Python 3.3+.
|
#error Cython requires Python 2.6+ or Python 3.3+.
|
||||||
#else
|
#else
|
||||||
#define CYTHON_ABI "0_29_30"
|
#define CYTHON_ABI "0_29_32"
|
||||||
#define CYTHON_HEX_VERSION 0x001D1EF0
|
#define CYTHON_HEX_VERSION 0x001D20F0
|
||||||
#define CYTHON_FUTURE_DIVISION 0
|
#define CYTHON_FUTURE_DIVISION 0
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 1
|
#define CYTHON_COMPILING_IN_PYPY 1
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#undef CYTHON_USE_TYPE_SLOTS
|
#undef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 0
|
#define CYTHON_USE_TYPE_SLOTS 0
|
||||||
#undef CYTHON_USE_PYTYPE_LOOKUP
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 1
|
#define CYTHON_COMPILING_IN_PYSTON 1
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -132,10 +134,56 @@
|
||||||
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
||||||
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(PY_NOGIL)
|
||||||
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 1
|
||||||
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
||||||
|
#ifndef CYTHON_USE_ASYNC_SLOTS
|
||||||
|
#define CYTHON_USE_ASYNC_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYLIST_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLIST_INTERNALS 0
|
||||||
|
#ifndef CYTHON_USE_UNICODE_INTERNALS
|
||||||
|
#define CYTHON_USE_UNICODE_INTERNALS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_UNICODE_WRITER
|
||||||
|
#define CYTHON_USE_UNICODE_WRITER 0
|
||||||
|
#undef CYTHON_USE_PYLONG_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLONG_INTERNALS 0
|
||||||
|
#ifndef CYTHON_AVOID_BORROWED_REFS
|
||||||
|
#define CYTHON_AVOID_BORROWED_REFS 0
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_ASSUME_SAFE_MACROS
|
||||||
|
#define CYTHON_ASSUME_SAFE_MACROS 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_UNPACK_METHODS
|
||||||
|
#define CYTHON_UNPACK_METHODS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_FAST_THREAD_STATE
|
||||||
|
#define CYTHON_FAST_THREAD_STATE 0
|
||||||
|
#undef CYTHON_FAST_PYCALL
|
||||||
|
#define CYTHON_FAST_PYCALL 0
|
||||||
|
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
||||||
|
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_USE_TP_FINALIZE
|
||||||
|
#define CYTHON_USE_TP_FINALIZE 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_DICT_VERSIONS
|
||||||
|
#define CYTHON_USE_DICT_VERSIONS 0
|
||||||
|
#undef CYTHON_USE_EXC_INFO_STACK
|
||||||
|
#define CYTHON_USE_EXC_INFO_STACK 0
|
||||||
#else
|
#else
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 1
|
#define CYTHON_COMPILING_IN_CPYTHON 1
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Generated by Cython 0.29.30 */
|
/* Generated by Cython 0.29.32 */
|
||||||
|
|
||||||
#ifndef PY_SSIZE_T_CLEAN
|
#ifndef PY_SSIZE_T_CLEAN
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
||||||
#error Cython requires Python 2.6+ or Python 3.3+.
|
#error Cython requires Python 2.6+ or Python 3.3+.
|
||||||
#else
|
#else
|
||||||
#define CYTHON_ABI "0_29_30"
|
#define CYTHON_ABI "0_29_32"
|
||||||
#define CYTHON_HEX_VERSION 0x001D1EF0
|
#define CYTHON_HEX_VERSION 0x001D20F0
|
||||||
#define CYTHON_FUTURE_DIVISION 0
|
#define CYTHON_FUTURE_DIVISION 0
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 1
|
#define CYTHON_COMPILING_IN_PYPY 1
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#undef CYTHON_USE_TYPE_SLOTS
|
#undef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 0
|
#define CYTHON_USE_TYPE_SLOTS 0
|
||||||
#undef CYTHON_USE_PYTYPE_LOOKUP
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 1
|
#define CYTHON_COMPILING_IN_PYSTON 1
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -132,10 +134,56 @@
|
||||||
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
||||||
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(PY_NOGIL)
|
||||||
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 1
|
||||||
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
||||||
|
#ifndef CYTHON_USE_ASYNC_SLOTS
|
||||||
|
#define CYTHON_USE_ASYNC_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYLIST_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLIST_INTERNALS 0
|
||||||
|
#ifndef CYTHON_USE_UNICODE_INTERNALS
|
||||||
|
#define CYTHON_USE_UNICODE_INTERNALS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_UNICODE_WRITER
|
||||||
|
#define CYTHON_USE_UNICODE_WRITER 0
|
||||||
|
#undef CYTHON_USE_PYLONG_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLONG_INTERNALS 0
|
||||||
|
#ifndef CYTHON_AVOID_BORROWED_REFS
|
||||||
|
#define CYTHON_AVOID_BORROWED_REFS 0
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_ASSUME_SAFE_MACROS
|
||||||
|
#define CYTHON_ASSUME_SAFE_MACROS 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_UNPACK_METHODS
|
||||||
|
#define CYTHON_UNPACK_METHODS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_FAST_THREAD_STATE
|
||||||
|
#define CYTHON_FAST_THREAD_STATE 0
|
||||||
|
#undef CYTHON_FAST_PYCALL
|
||||||
|
#define CYTHON_FAST_PYCALL 0
|
||||||
|
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
||||||
|
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_USE_TP_FINALIZE
|
||||||
|
#define CYTHON_USE_TP_FINALIZE 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_DICT_VERSIONS
|
||||||
|
#define CYTHON_USE_DICT_VERSIONS 0
|
||||||
|
#undef CYTHON_USE_EXC_INFO_STACK
|
||||||
|
#define CYTHON_USE_EXC_INFO_STACK 0
|
||||||
#else
|
#else
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 1
|
#define CYTHON_COMPILING_IN_CPYTHON 1
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Generated by Cython 0.29.30 */
|
/* Generated by Cython 0.29.32 */
|
||||||
|
|
||||||
#ifndef PY_SSIZE_T_CLEAN
|
#ifndef PY_SSIZE_T_CLEAN
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
|
||||||
#error Cython requires Python 2.6+ or Python 3.3+.
|
#error Cython requires Python 2.6+ or Python 3.3+.
|
||||||
#else
|
#else
|
||||||
#define CYTHON_ABI "0_29_30"
|
#define CYTHON_ABI "0_29_32"
|
||||||
#define CYTHON_HEX_VERSION 0x001D1EF0
|
#define CYTHON_HEX_VERSION 0x001D20F0
|
||||||
#define CYTHON_FUTURE_DIVISION 0
|
#define CYTHON_FUTURE_DIVISION 0
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 1
|
#define CYTHON_COMPILING_IN_PYPY 1
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#undef CYTHON_USE_TYPE_SLOTS
|
#undef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 0
|
#define CYTHON_USE_TYPE_SLOTS 0
|
||||||
#undef CYTHON_USE_PYTYPE_LOOKUP
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
@ -92,6 +93,7 @@
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 1
|
#define CYTHON_COMPILING_IN_PYSTON 1
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 0
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -132,10 +134,56 @@
|
||||||
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
#ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
|
||||||
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
#define CYTHON_UPDATE_DESCRIPTOR_DOC 0
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(PY_NOGIL)
|
||||||
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
|
#define CYTHON_COMPILING_IN_CPYTHON 0
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 1
|
||||||
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYTYPE_LOOKUP
|
||||||
|
#define CYTHON_USE_PYTYPE_LOOKUP 0
|
||||||
|
#ifndef CYTHON_USE_ASYNC_SLOTS
|
||||||
|
#define CYTHON_USE_ASYNC_SLOTS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_PYLIST_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLIST_INTERNALS 0
|
||||||
|
#ifndef CYTHON_USE_UNICODE_INTERNALS
|
||||||
|
#define CYTHON_USE_UNICODE_INTERNALS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_UNICODE_WRITER
|
||||||
|
#define CYTHON_USE_UNICODE_WRITER 0
|
||||||
|
#undef CYTHON_USE_PYLONG_INTERNALS
|
||||||
|
#define CYTHON_USE_PYLONG_INTERNALS 0
|
||||||
|
#ifndef CYTHON_AVOID_BORROWED_REFS
|
||||||
|
#define CYTHON_AVOID_BORROWED_REFS 0
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_ASSUME_SAFE_MACROS
|
||||||
|
#define CYTHON_ASSUME_SAFE_MACROS 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_UNPACK_METHODS
|
||||||
|
#define CYTHON_UNPACK_METHODS 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_FAST_THREAD_STATE
|
||||||
|
#define CYTHON_FAST_THREAD_STATE 0
|
||||||
|
#undef CYTHON_FAST_PYCALL
|
||||||
|
#define CYTHON_FAST_PYCALL 0
|
||||||
|
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
|
||||||
|
#define CYTHON_PEP489_MULTI_PHASE_INIT 1
|
||||||
|
#endif
|
||||||
|
#ifndef CYTHON_USE_TP_FINALIZE
|
||||||
|
#define CYTHON_USE_TP_FINALIZE 1
|
||||||
|
#endif
|
||||||
|
#undef CYTHON_USE_DICT_VERSIONS
|
||||||
|
#define CYTHON_USE_DICT_VERSIONS 0
|
||||||
|
#undef CYTHON_USE_EXC_INFO_STACK
|
||||||
|
#define CYTHON_USE_EXC_INFO_STACK 0
|
||||||
#else
|
#else
|
||||||
#define CYTHON_COMPILING_IN_PYPY 0
|
#define CYTHON_COMPILING_IN_PYPY 0
|
||||||
#define CYTHON_COMPILING_IN_PYSTON 0
|
#define CYTHON_COMPILING_IN_PYSTON 0
|
||||||
#define CYTHON_COMPILING_IN_CPYTHON 1
|
#define CYTHON_COMPILING_IN_CPYTHON 1
|
||||||
|
#define CYTHON_COMPILING_IN_NOGIL 0
|
||||||
#ifndef CYTHON_USE_TYPE_SLOTS
|
#ifndef CYTHON_USE_TYPE_SLOTS
|
||||||
#define CYTHON_USE_TYPE_SLOTS 1
|
#define CYTHON_USE_TYPE_SLOTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -593,6 +593,22 @@ def _fetch_reference_injections( # noqa: C901
|
||||||
return injections, closing
|
return injections, closing
|
||||||
|
|
||||||
|
|
||||||
|
def _locate_dependent_closing_args(provider: providers.Provider) -> Dict[str, providers.Provider]:
|
||||||
|
if not hasattr(provider, "args"):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
closing_deps = {}
|
||||||
|
for arg in provider.args:
|
||||||
|
if not isinstance(arg, providers.Provider) or not hasattr(arg, "args"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not arg.args and isinstance(arg, providers.Resource):
|
||||||
|
return {str(id(arg)): arg}
|
||||||
|
else:
|
||||||
|
closing_deps += _locate_dependent_closing_args(arg)
|
||||||
|
return closing_deps
|
||||||
|
|
||||||
|
|
||||||
def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> None:
|
def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> None:
|
||||||
patched_callable = _patched_registry.get_callable(fn)
|
patched_callable = _patched_registry.get_callable(fn)
|
||||||
if patched_callable is None:
|
if patched_callable is None:
|
||||||
|
@ -614,6 +630,9 @@ def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> Non
|
||||||
|
|
||||||
if injection in patched_callable.reference_closing:
|
if injection in patched_callable.reference_closing:
|
||||||
patched_callable.add_closing(injection, provider)
|
patched_callable.add_closing(injection, provider)
|
||||||
|
deps = _locate_dependent_closing_args(provider)
|
||||||
|
for key, dep in deps.items():
|
||||||
|
patched_callable.add_closing(key, dep)
|
||||||
|
|
||||||
|
|
||||||
def _unbind_injections(fn: Callable[..., Any]) -> None:
|
def _unbind_injections(fn: Callable[..., Any]) -> None:
|
||||||
|
|
|
@ -45,7 +45,7 @@ var4: List[int] = provider4()
|
||||||
|
|
||||||
# Test 5: to check the return type with async function
|
# Test 5: to check the return type with async function
|
||||||
async def init5() -> List[int]:
|
async def init5() -> List[int]:
|
||||||
...
|
return []
|
||||||
|
|
||||||
|
|
||||||
provider5 = providers.Resource(init5)
|
provider5 = providers.Resource(init5)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""AbstractCoroutine provider tests."""
|
"""AbstractCoroutine provider tests."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
|
|
||||||
from dependency_injector import providers, errors
|
from dependency_injector import providers, errors
|
||||||
from pytest import mark, raises
|
from pytest import mark, raises
|
||||||
|
@ -12,6 +13,7 @@ def test_inheritance():
|
||||||
assert isinstance(providers.AbstractCoroutine(example), providers.Coroutine)
|
assert isinstance(providers.AbstractCoroutine(example), providers.Coroutine)
|
||||||
|
|
||||||
|
|
||||||
|
@mark.skipif(sys.version_info >= (3, 11), reason="asyncio.coroutine removed in Python 3.11")
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
@mark.filterwarnings("ignore")
|
@mark.filterwarnings("ignore")
|
||||||
async def test_call_overridden_by_coroutine():
|
async def test_call_overridden_by_coroutine():
|
||||||
|
@ -26,6 +28,7 @@ async def test_call_overridden_by_coroutine():
|
||||||
assert result == (1, 2, 3, 4)
|
assert result == (1, 2, 3, 4)
|
||||||
|
|
||||||
|
|
||||||
|
@mark.skipif(sys.version_info >= (3, 11), reason="asyncio.coroutine removed in Python 3.11")
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
@mark.filterwarnings("ignore")
|
@mark.filterwarnings("ignore")
|
||||||
async def test_call_overridden_by_delegated_coroutine():
|
async def test_call_overridden_by_delegated_coroutine():
|
||||||
|
|
|
@ -20,6 +20,11 @@ class Service:
|
||||||
cls.shutdown_counter += 1
|
cls.shutdown_counter += 1
|
||||||
|
|
||||||
|
|
||||||
|
class FactoryService:
|
||||||
|
def __init__(self, service: Service):
|
||||||
|
self.service = service
|
||||||
|
|
||||||
|
|
||||||
def init_service():
|
def init_service():
|
||||||
service = Service()
|
service = Service()
|
||||||
service.init()
|
service.init()
|
||||||
|
@ -30,8 +35,14 @@ def init_service():
|
||||||
class Container(containers.DeclarativeContainer):
|
class Container(containers.DeclarativeContainer):
|
||||||
|
|
||||||
service = providers.Resource(init_service)
|
service = providers.Resource(init_service)
|
||||||
|
factory_service = providers.Factory(FactoryService, service)
|
||||||
|
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def test_function(service: Service = Closing[Provide["service"]]):
|
def test_function(service: Service = Closing[Provide["service"]]):
|
||||||
return service
|
return service
|
||||||
|
|
||||||
|
|
||||||
|
@inject
|
||||||
|
def test_function_dependency(factory: FactoryService = Closing[Provide["factory_service"]]):
|
||||||
|
return factory
|
||||||
|
|
|
@ -289,6 +289,23 @@ def test_closing_resource():
|
||||||
assert result_1 is not result_2
|
assert result_1 is not result_2
|
||||||
|
|
||||||
|
|
||||||
|
@mark.usefixtures("resourceclosing_container")
|
||||||
|
def test_closing_dependency_resource():
|
||||||
|
resourceclosing.Service.reset_counter()
|
||||||
|
|
||||||
|
result_1 = resourceclosing.test_function_dependency()
|
||||||
|
assert isinstance(result_1, resourceclosing.FactoryService)
|
||||||
|
assert result_1.service.init_counter == 1
|
||||||
|
assert result_1.service.shutdown_counter == 1
|
||||||
|
|
||||||
|
result_2 = resourceclosing.test_function_dependency()
|
||||||
|
assert isinstance(result_2, resourceclosing.FactoryService)
|
||||||
|
assert result_2.service.init_counter == 2
|
||||||
|
assert result_2.service.shutdown_counter == 2
|
||||||
|
|
||||||
|
assert result_1 is not result_2
|
||||||
|
|
||||||
|
|
||||||
@mark.usefixtures("resourceclosing_container")
|
@mark.usefixtures("resourceclosing_container")
|
||||||
def test_closing_resource_bypass_marker_injection():
|
def test_closing_resource_bypass_marker_injection():
|
||||||
resourceclosing.Service.reset_counter()
|
resourceclosing.Service.reset_counter()
|
||||||
|
|
10
tox.ini
10
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist=
|
envlist=
|
||||||
coveralls, pylint, flake8, pydocstyle, 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, pypy2, pypy3
|
coveralls, pylint, flake8, pydocstyle, 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, pypy2.7, pypy3.9
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps=
|
deps=
|
||||||
|
@ -23,8 +23,8 @@ 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_*
|
||||||
basepython=python3.10
|
basepython=python3.11
|
||||||
usedevelop=True
|
usedevelop=True
|
||||||
deps=
|
deps=
|
||||||
{[testenv]deps}
|
{[testenv]deps}
|
||||||
|
@ -55,7 +55,7 @@ extras=
|
||||||
flask
|
flask
|
||||||
commands = pytest -c tests/.configs/pytest-py35.ini
|
commands = pytest -c tests/.configs/pytest-py35.ini
|
||||||
|
|
||||||
[testenv:pypy2]
|
[testenv:pypy2.7]
|
||||||
deps=
|
deps=
|
||||||
pytest
|
pytest
|
||||||
extras=
|
extras=
|
||||||
|
@ -63,7 +63,7 @@ extras=
|
||||||
flask
|
flask
|
||||||
commands = pytest -c tests/.configs/pytest-py27.ini
|
commands = pytest -c tests/.configs/pytest-py27.ini
|
||||||
|
|
||||||
[testenv:pypy3]
|
[testenv:pypy3.9]
|
||||||
deps=
|
deps=
|
||||||
pytest
|
pytest
|
||||||
pytest-asyncio
|
pytest-asyncio
|
||||||
|
|
Loading…
Reference in New Issue
Block a user