Merge branch 'release/4.10.1' into master

This commit is contained in:
Roman Mogylatov 2021-01-18 21:03:09 -05:00
commit 2cfc61aa37
7 changed files with 42 additions and 3 deletions

View File

@ -3,7 +3,7 @@ dist: xenial
language: python language: python
jobs: jobs:
include: include:
- python: 3.8 - python: 3.9
env: TOXENV=coveralls DEPENDENCY_INJECTOR_DEBUG_MODE=1 env: TOXENV=coveralls DEPENDENCY_INJECTOR_DEBUG_MODE=1
install: install:
- pip install tox - pip install tox

View File

@ -7,6 +7,15 @@ 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.10.1
------
- Fix a Python 3.9 specific bug in ``wiring`` module: introspection doesn't work for
builtin ``types.GenericAlias``. This resulted in wiring failure for modules
importing ``queue.Queue``.
See issue `#362 <https://github.com/ets-labs/python-dependency-injector/issues/362>`_.
Thanks `@ventaquil <https://github.com/ventaquil>`_ for the bug report.
- Switch Coveralls reporting Travis Job to run on Python 3.9.
4.10.0 4.10.0
------ ------
- Add ``strict`` mode and ``required`` modifier for ``Configuration`` provider. - Add ``strict`` mode and ``required`` modifier for ``Configuration`` provider.

View File

@ -1,6 +1,6 @@
"""Top-level package.""" """Top-level package."""
__version__ = '4.10.0' __version__ = '4.10.1'
"""Version number. """Version number.
:type: str :type: str

View File

@ -28,6 +28,12 @@ else:
class GenericMeta(type): class GenericMeta(type):
... ...
# Hotfix, see: https://github.com/ets-labs/python-dependency-injector/issues/362
if sys.version_info >= (3, 9):
from types import GenericAlias
else:
GenericAlias = None
try: try:
from fastapi.params import Depends as FastAPIDepends from fastapi.params import Depends as FastAPIDepends
@ -333,6 +339,10 @@ def _unpatch(
def _fetch_reference_injections( def _fetch_reference_injections(
fn: Callable[..., Any], fn: Callable[..., Any],
) -> Tuple[Dict[str, Any], Dict[str, Any]]: ) -> Tuple[Dict[str, Any], Dict[str, Any]]:
# # Hotfix, see: https://github.com/ets-labs/python-dependency-injector/issues/362
if GenericAlias and fn is GenericAlias:
fn = fn.__init__
signature = inspect.signature(fn) signature = inspect.signature(fn)
injections = {} injections = {}

View File

@ -0,0 +1,5 @@
# Hotfix, see: https://github.com/ets-labs/python-dependency-injector/issues/362
from queue import Queue
__all__ = ('Queue',)

View File

@ -263,6 +263,21 @@ class WiringTest(unittest.TestCase):
self.assertIsInstance(service, Service) self.assertIsInstance(service, Service)
class WiringAndQueue(unittest.TestCase):
def test_wire_queue(self) -> None:
from wiringsamples import queuemodule
container = Container()
self.addCleanup(container.unwire)
# Should not raise exception
# See: https://github.com/ets-labs/python-dependency-injector/issues/362
try:
container.wire(modules=[queuemodule])
except:
raise
class WiringAndFastAPITest(unittest.TestCase): class WiringAndFastAPITest(unittest.TestCase):
container: Container container: Container

View File

@ -18,7 +18,7 @@ commands=
[testenv:coveralls] [testenv:coveralls]
passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH DEPENDENCY_INJECTOR_DEBUG_MODE passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH DEPENDENCY_INJECTOR_DEBUG_MODE
basepython=python3.8 basepython=python3.9
usedevelop=True usedevelop=True
deps= deps=
{[testenv]deps} {[testenv]deps}