Skip to content

Commit

Permalink
Merge branch 'release/4.41.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmk135 committed Dec 19, 2022
2 parents 3858cef + 4bfdf89 commit cc2304e
Show file tree
Hide file tree
Showing 24 changed files with 344 additions and 122 deletions.
82 changes: 40 additions & 42 deletions .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publishing

on:
workflow_dispatch:
push:
tags:
- '*'
Expand All @@ -9,28 +10,28 @@ jobs:

tests:
name: Run tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: pip install tox
- run: tox
env:
TOXENV: "3.10"
TOXENV: 3.11

linters:
name: Run linters
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
toxenv: [flake8, pydocstyle, mypy, pylint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: pip install tox
- run: tox
env:
Expand All @@ -39,14 +40,14 @@ jobs:
build-sdist:
name: Build source tarball
needs: [tests, linters]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: python setup.py sdist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: ./dist/*

Expand All @@ -56,63 +57,60 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-10.15]
os: [ubuntu-22.04, windows-2019, macos-11]
env:
CIBW_SKIP: cp27-win*
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- run: pip install cibuildwheel==2.1.3
- run: cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build-wheels-linux-aarch64:
name: Build wheels (ubuntu-latest-aarch64)
name: Build wheels (ubuntu-22.04-aarch64)
needs: [tests, linters]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- run: pip install cibuildwheel==2.1.3
- run: cibuildwheel --archs aarch64 --output-dir wheelhouse
- uses: actions/upload-artifact@v2
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: aarch64
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

publish:
name: Publish on PyPI
needs: [build-sdist, build-wheels, build-wheels-linux-aarch64]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# For publishing to Test PyPI, uncomment next two lines:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# For publishing to Test PyPI, uncomment next two lines:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/

publish-docs:
name: Publish docs
needs: [publish]
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: pip install -r requirements-doc.txt
- run: pip install awscli
- run: pip install -e .
Expand Down
34 changes: 25 additions & 9 deletions .github/workflows/tests-and-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@ on: [push, pull_request, workflow_dispatch]

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:
name: Run tests
runs-on: ubuntu-latest
strategy:
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:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: pip install tox
Expand All @@ -28,10 +44,10 @@ jobs:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: pip install tox cython
- run: make cythonize
- run: tox
Expand All @@ -45,10 +61,10 @@ jobs:
matrix:
toxenv: [flake8, pydocstyle, mypy, pylint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: 3.11
- run: pip install tox
- run: tox
env:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:target: https://pypi.org/project/dependency-injector/
: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
:alt: Build Status

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Dependency Injector --- Dependency injection framework for Python
:target: https://pypi.org/project/dependency-injector/
: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
:alt: Build Status

Expand Down
16 changes: 16 additions & 0 deletions docs/main/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
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/[email protected]``,
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
------
- Add ``Configuration.from_json()`` method to load configuration from a json file.
Expand Down
11 changes: 6 additions & 5 deletions docs/providers/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ To create a custom provider you need to follow these rules:
1. New provider class should inherit :py:class:`Provider`.
2. You need to implement the ``Provider._provide()`` method.
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
from the ``providers`` module. After the a new provider object is created use
``Provider._copy_overriding()`` method to copy all overriding providers. See the example
below.
equivalent copy of a provider. All providers must be copied with the ``deepcopy()`` function
from the ``providers`` module. It's essential to pass ``memo`` into ``deepcopy`` in order to keep
the preconfigured ``args`` and ``kwargs`` of stored providers. After the a new provider object
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
``Provider.__init__()``.
5. If new provider stores any other providers, these providers should be listed in
Expand All @@ -33,7 +34,7 @@ To create a custom provider you need to follow these rules:
.. note::
1. Prefer delegation over inheritance. If you choose between inheriting a ``Factory`` or
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
will also save some memory.

Expand Down
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-buster
FROM python:3.10-buster

ENV PYTHONUNBUFFERED=1

Expand Down
57 changes: 24 additions & 33 deletions examples/miniapps/fastapi-redis/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,26 @@ The output should be something like:

.. code-block::
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # 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
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # Configuration loaded
redis_1 | 1:M 04 Jan 2022 02:42:14.116 * Running mode=standalone, port=6379.
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.
redis_1 | 1:M 04 Jan 2022 02:42:14.116 # Server initialized
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Loading RDB produced by version 6.0.9
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB age 1 seconds
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB memory usage when created 0.77 Mb
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Ready to accept connections
redis_1 | 1:signal-handler (1609728137) Received SIGTERM scheduling shutdown...
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # User requested shutdown...
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # Redis is now ready to exit, bye bye...
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
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
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # Configuration loaded
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Running mode=standalone, port=6379.
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.
redis_1 | 1:M 04 Jan 2022 02:42:22.037 # Server initialized
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)
fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
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
fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # Configuration loaded
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * monotonic clock: POSIX clock_gettime
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * Running mode=standalone, port=6379.
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 # Server initialized
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Loading RDB produced by version 7.0.5
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB age 58 seconds
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB memory usage when created 0.85 Mb
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Done loading RDB, keys loaded: 0, keys expired: 0.
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * DB loaded from disk: 0.000 seconds
fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.488 * Ready to accept connections
fastapi-redis-example-1 | INFO: Started server process [1]
fastapi-redis-example-1 | INFO: Waiting for application startup.
fastapi-redis-example-1 | INFO: Application startup complete.
fastapi-redis-example-1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET /favicon.ico HTTP/1.1" 404 Not Found
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
Test
----
Expand All @@ -69,9 +60,9 @@ The output should be something like:

.. 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
plugins: cov-2.10.1, asyncio-0.14.0
plugins: cov-4.0.0, asyncio-0.20.3
collected 1 item
fastapiredis/tests.py . [100%]
Expand All @@ -80,10 +71,10 @@ The output should be something like:
Name Stmts Miss Cover
-------------------------------------------------
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/redis.py 7 4 43%
fastapiredis/services.py 7 3 57%
fastapiredis/tests.py 18 0 100%
-------------------------------------------------
TOTAL 53 7 87%
TOTAL 52 7 87%
12 changes: 5 additions & 7 deletions examples/miniapps/fastapi-redis/fastapiredis/redis.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""Redis client module."""

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]:
pool = await create_redis_pool(f"redis://{host}", password=password)
yield pool
pool.close()
await pool.wait_closed()
session = from_url(f"redis://{host}", password=password, encoding="utf-8", decode_responses=True)
yield session
session.close()
await session.wait_closed()
2 changes: 1 addition & 1 deletion examples/miniapps/fastapi-redis/fastapiredis/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def __init__(self, redis: Redis) -> None:

async def process(self) -> str:
await self._redis.set("my-key", "value")
return await self._redis.get("my-key", encoding="utf-8")
return await self._redis.get("my-key")
Loading

0 comments on commit cc2304e

Please sign in to comment.