Skip to content

Commit cf039a0

Browse files
committed
Merge branch 'release/4.36.1' into master
2 parents cef6d35 + 980914c commit cf039a0

File tree

9 files changed

+52
-15
lines changed

9 files changed

+52
-15
lines changed

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252

5353
# General information about the project.
5454
project = u'Dependency Injector'
55-
copyright = u'2021, ETS Labs'
56-
author = u'ETS Labs'
55+
copyright = u'2021, Roman Mogylatov'
56+
author = u'Roman Mogylatov'
5757

5858
# The version info for the project you're documenting, acts as replacement for
5959
# |version| and |release|, also used in various other places throughout the
@@ -232,7 +232,7 @@
232232
# author, documentclass [howto, manual, or own class]).
233233
latex_documents = [
234234
(master_doc, 'dependency_injector.tex', u'Dependency Injector Documentation',
235-
u'ETS Labs', 'manual'),
235+
u'Roman Mogylatov', 'manual'),
236236
]
237237

238238
# The name of an image file (relative to this directory) to place at the top of
@@ -303,7 +303,7 @@
303303
'github_button': True,
304304
'github_banner': True,
305305
'logo': 'logo.svg',
306-
'description': 'Dependency injection framework for Python',
306+
'description': 'Dependency injection framework for Python by Roman Mogylatov',
307307
'code_font_size': '10pt',
308308
'analytics_id': 'UA-67012059-1',
309309
}

docs/examples/boto3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Boto3 example
88
:description: This example demonstrates a usage of Boto3 AWS client and Dependency Injector.
99

1010

11-
This example shows how to use ``Dependency Injector`` with `Boto3 <https://www.djangoproject.com/>`_.
11+
This example shows how to use ``Dependency Injector`` with `Boto3 <https://github.com/boto/boto3>`_.
1212

1313
The source code is available on the `Github <https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/boto3-session>`_.
1414

docs/main/changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ that were made in every particular version.
77
From version 0.7.6 *Dependency Injector* framework strictly
88
follows `Semantic versioning`_
99

10+
11+
4.36.1
12+
------
13+
- Fix a wiring bug with improper resolving of ``Provide[some_provider.provider]``.
14+
- Fix a typo in ``Factory`` provider docs ``service.add_attributes(clent=client)``
15+
`#499 <https://github.com/ets-labs/python-dependency-injector/issues/499>`_.
16+
Thanks to `@rajanjha786 <https://github.com/rajanjha786>`_ for the contribution.
17+
- Fix a typo in ``boto3`` example
18+
`#511 <https://github.com/ets-labs/python-dependency-injector/issues/511>`_.
19+
Thanks to `@whysage <https://github.com/whysage>`_ for the contribution.
20+
1021
4.36.0
1122
------
1223
- Add support of non-string keys for ``FactoryAggregate`` provider.

docs/wiring.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,29 @@ a function or method argument:
3939
4040
Specifying an annotation is optional.
4141

42-
There are two types of markers:
42+
To inject the provider itself use ``Provide[foo.provider]``:
4343

44-
- ``Provide[foo]`` - call the provider ``foo`` and injects the result
45-
- ``Provider[foo]`` - injects the provider ``foo`` itself
44+
.. code-block:: python
45+
46+
from dependency_injector.providers import Factory
47+
from dependency_injector.wiring import inject, Provide
48+
49+
50+
@inject
51+
def foo(bar_provider: Factory[Bar] = Provide[Container.bar.provider]):
52+
bar = bar_provider(argument="baz")
53+
...
54+
You can also use ``Provider[foo]`` for injecting the provider itself:
4655

4756
.. code-block:: python
4857
58+
from dependency_injector.providers import Factory
4959
from dependency_injector.wiring import inject, Provider
5060
5161
5262
@inject
53-
def foo(bar_provider: Callable[..., Bar] = Provider[Container.bar]):
54-
bar = bar_provider()
63+
def foo(bar_provider: Factory[Bar] = Provider[Container.bar]):
64+
bar = bar_provider(argument="baz")
5565
...
5666
5767
You can use configuration, provided instance and sub-container providers as you normally do.

examples/providers/factory_attribute_injections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Container(containers.DeclarativeContainer):
1717
client = providers.Factory(Client)
1818

1919
service = providers.Factory(Service)
20-
service.add_attributes(clent=client)
20+
service.add_attributes(client=client)
2121

2222

2323
if __name__ == '__main__':

src/dependency_injector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Top-level package."""
22

3-
__version__ = '4.36.0'
3+
__version__ = '4.36.1'
44
"""Version number.
55
66
:type: str

src/dependency_injector/wiring.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ def _resolve_delegate(
226226
self,
227227
original: providers.Delegate,
228228
) -> Optional[providers.Provider]:
229-
return self._resolve_provider(original.provides)
229+
provider = self._resolve_provider(original.provides)
230+
if provider:
231+
provider = provider.provider
232+
return provider
230233

231234
def _resolve_config_option(
232235
self,
@@ -539,7 +542,10 @@ def _bind_injections(fn: Callable[..., Any], providers_map: ProvidersMap) -> Non
539542
if isinstance(marker, Provide):
540543
fn.__injections__[injection] = provider
541544
elif isinstance(marker, Provider):
542-
fn.__injections__[injection] = provider.provider
545+
if isinstance(provider, providers.Delegate):
546+
fn.__injections__[injection] = provider
547+
else:
548+
fn.__injections__[injection] = provider.provider
543549

544550
if injection in fn.__reference_closing__:
545551
fn.__closing__[injection] = provider

tests/unit/samples/wiringsamples/module.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ def test_config_value_required_undefined(
8484

8585

8686
@inject
87-
def test_provide_provider(service_provider: Callable[..., Service] = Provider[Container.service.provider]):
87+
def test_provide_provider(service_provider: Callable[..., Service] = Provide[Container.service.provider]):
88+
service = service_provider()
89+
return service
90+
91+
92+
@inject
93+
def test_provider_provider(service_provider: Callable[..., Service] = Provider[Container.service.provider]):
8894
service = service_provider()
8995
return service
9096

tests/unit/wiring/test_wiring_py36.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def test_provide_provider(self):
169169
service = module.test_provide_provider()
170170
self.assertIsInstance(service, Service)
171171

172+
def test_provider_provider(self):
173+
service = module.test_provider_provider()
174+
self.assertIsInstance(service, Service)
175+
172176
def test_provided_instance(self):
173177
class TestService:
174178
foo = {

0 commit comments

Comments
 (0)