Deprecate declarative container decorators (#303)

This commit is contained in:
Roman Mogylatov 2020-10-16 21:43:21 -04:00 committed by GitHub
parent 11ac677d42
commit f1867b6bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1288 additions and 1133 deletions

View File

@ -7,6 +7,11 @@ 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`_
Development version
-------------------
- Deprecate ``@containers.override()`` and ``@containers.copy()`` decorators.
- Update changelog of version ``4.0.0`` so it lists all deprecated features.
4.0.2 4.0.2
----- -----
- Fix typing stubs for ``@container.override()`` and ``@containers.copy()`` decorators ( - Fix typing stubs for ``@container.override()`` and ``@containers.copy()`` decorators (
@ -33,6 +38,8 @@ Deprecations:
- Deprecate ``ext.aiohttp`` module in favor of ``wiring`` feature. - Deprecate ``ext.aiohttp`` module in favor of ``wiring`` feature.
- Deprecate ``ext.flask`` module in favor of ``wiring`` feature. - Deprecate ``ext.flask`` module in favor of ``wiring`` feature.
- Deprecate ``.delegate()`` provider method in favor of ``.provider`` attribute. - Deprecate ``.delegate()`` provider method in favor of ``.provider`` attribute.
- Deprecate ``@containers.override()`` decorator in favor of overriding container on instance level.
- Deprecate ``@containers.copy()`` decorator.
Removals: Removals:

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
"""Containers module.""" """Containers module."""
import sys import sys
import warnings
import six import six
@ -427,6 +428,11 @@ def override(object container):
:return: Declarative container's overriding decorator. :return: Declarative container's overriding decorator.
:rtype: callable(:py:class:`DeclarativeContainer`) :rtype: callable(:py:class:`DeclarativeContainer`)
""" """
warnings.warn(
'Decorator "@override()" is deprecated since version 4.0.3. '
'Use overriding on instance level instead "container.override(AnotherContainer())".',
category=DeprecationWarning,
)
def _decorator(object overriding_container): def _decorator(object overriding_container):
"""Overriding decorator.""" """Overriding decorator."""
container.override(overriding_container) container.override(overriding_container)
@ -447,6 +453,10 @@ def copy(object container):
:return: Declarative container's copying decorator. :return: Declarative container's copying decorator.
:rtype: callable(:py:class:`DeclarativeContainer`) :rtype: callable(:py:class:`DeclarativeContainer`)
""" """
warnings.warn(
'Decorator "@copy()" is deprecated since version 4.0.3.',
category=DeprecationWarning,
)
def _decorator(copied_container): def _decorator(copied_container):
cdef dict memo = dict() cdef dict memo = dict()
for name, provider in six.iteritems(copied_container.cls_providers): for name, provider in six.iteritems(copied_container.cls_providers):