mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Drop backward compatibilities of 1.x
This commit is contained in:
parent
93bab98859
commit
7392f35991
|
@ -1,126 +1,7 @@
|
|||
"""Dependency injector."""
|
||||
|
||||
from dependency_injector.catalogs import (
|
||||
DeclarativeCatalog,
|
||||
AbstractCatalog,
|
||||
DynamicCatalog,
|
||||
CatalogBundle,
|
||||
override,
|
||||
)
|
||||
|
||||
from dependency_injector.providers import (
|
||||
Provider,
|
||||
Delegate,
|
||||
Callable,
|
||||
DelegatedCallable,
|
||||
Factory,
|
||||
DelegatedFactory,
|
||||
Singleton,
|
||||
DelegatedSingleton,
|
||||
ExternalDependency,
|
||||
StaticProvider,
|
||||
Class,
|
||||
Object,
|
||||
Function,
|
||||
Value,
|
||||
Config,
|
||||
)
|
||||
|
||||
from dependency_injector.injections import (
|
||||
Injection,
|
||||
Arg,
|
||||
KwArg,
|
||||
Attribute,
|
||||
Method,
|
||||
inject,
|
||||
)
|
||||
|
||||
from dependency_injector.utils import (
|
||||
is_provider,
|
||||
ensure_is_provider,
|
||||
is_delegated_provider,
|
||||
is_injection,
|
||||
ensure_is_injection,
|
||||
is_arg_injection,
|
||||
is_kwarg_injection,
|
||||
is_attribute_injection,
|
||||
is_method_injection,
|
||||
is_catalog,
|
||||
is_dynamic_catalog,
|
||||
is_declarative_catalog,
|
||||
is_catalog_bundle,
|
||||
ensure_is_catalog_bundle,
|
||||
)
|
||||
|
||||
from dependency_injector.errors import (
|
||||
Error,
|
||||
UndefinedProviderError,
|
||||
)
|
||||
|
||||
# Backward compatibility for versions < 0.11.*
|
||||
from dependency_injector import catalogs
|
||||
catalog = catalogs
|
||||
"""Dependency injector top-level package."""
|
||||
|
||||
VERSION = '2.0.0'
|
||||
"""Version number that follows semantic versioning.
|
||||
|
||||
:type: str
|
||||
"""
|
||||
|
||||
|
||||
__all__ = (
|
||||
# Catalogs
|
||||
'DeclarativeCatalog',
|
||||
'AbstractCatalog',
|
||||
'DynamicCatalog',
|
||||
'CatalogBundle',
|
||||
'override',
|
||||
|
||||
# Providers
|
||||
'Provider',
|
||||
'Delegate',
|
||||
'Callable',
|
||||
'DelegatedCallable',
|
||||
'Factory',
|
||||
'DelegatedFactory',
|
||||
'Singleton',
|
||||
'DelegatedSingleton',
|
||||
'ExternalDependency',
|
||||
'StaticProvider',
|
||||
'Class',
|
||||
'Object',
|
||||
'Function',
|
||||
'Value',
|
||||
'Config',
|
||||
|
||||
# Injections
|
||||
'Injection',
|
||||
'Arg',
|
||||
'KwArg',
|
||||
'Attribute',
|
||||
'Method',
|
||||
'inject',
|
||||
|
||||
# Utils
|
||||
'is_provider',
|
||||
'ensure_is_provider',
|
||||
'is_delegated_provider',
|
||||
'is_injection',
|
||||
'ensure_is_injection',
|
||||
'is_arg_injection',
|
||||
'is_kwarg_injection',
|
||||
'is_attribute_injection',
|
||||
'is_method_injection',
|
||||
'is_catalog',
|
||||
'is_dynamic_catalog',
|
||||
'is_declarative_catalog',
|
||||
'is_catalog_bundle',
|
||||
'ensure_is_catalog_bundle',
|
||||
|
||||
# Errors
|
||||
'Error',
|
||||
'UndefinedProviderError',
|
||||
|
||||
# Version
|
||||
'VERSION'
|
||||
)
|
||||
|
|
|
@ -5,7 +5,6 @@ from dependency_injector.catalogs.dynamic import DynamicCatalog
|
|||
from dependency_injector.catalogs.declarative import (
|
||||
DeclarativeCatalogMetaClass,
|
||||
DeclarativeCatalog,
|
||||
AbstractCatalog,
|
||||
)
|
||||
from dependency_injector.catalogs.utils import (
|
||||
copy,
|
||||
|
@ -18,7 +17,6 @@ __all__ = (
|
|||
'DynamicCatalog',
|
||||
'DeclarativeCatalogMetaClass',
|
||||
'DeclarativeCatalog',
|
||||
'AbstractCatalog',
|
||||
'copy',
|
||||
'override',
|
||||
)
|
||||
|
|
|
@ -368,8 +368,6 @@ class DeclarativeCatalog(object):
|
|||
"""
|
||||
return cls._catalog.get_provider(name)
|
||||
|
||||
get = get_provider # Backward compatibility for versions < 0.11.*
|
||||
|
||||
@classmethod
|
||||
def bind_provider(cls, name, provider, force=False,
|
||||
_set_as_attribute=True):
|
||||
|
@ -429,8 +427,6 @@ class DeclarativeCatalog(object):
|
|||
"""
|
||||
return hasattr(cls, name)
|
||||
|
||||
has = has_provider # Backward compatibility for versions < 0.11.*
|
||||
|
||||
@classmethod
|
||||
def unbind_provider(cls, name):
|
||||
"""Remove provider binding.
|
||||
|
@ -485,7 +481,3 @@ class DeclarativeCatalog(object):
|
|||
:rtype: None
|
||||
"""
|
||||
raise NotImplementedError('Implementated in metaclass')
|
||||
|
||||
|
||||
# Backward compatibility for versions < 0.11.*
|
||||
AbstractCatalog = DeclarativeCatalog
|
||||
|
|
|
@ -4,7 +4,6 @@ from dependency_injector.providers.base import (
|
|||
Provider,
|
||||
Delegate,
|
||||
Static,
|
||||
StaticProvider,
|
||||
ExternalDependency,
|
||||
)
|
||||
from dependency_injector.providers.callable import (
|
||||
|
|
|
@ -276,10 +276,6 @@ class Static(Provider):
|
|||
__repr__ = __str__
|
||||
|
||||
|
||||
StaticProvider = Static
|
||||
# Backward compatibility for versions < 1.11.1
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class ExternalDependency(Provider):
|
||||
""":py:class:`ExternalDependency` provider describes dependency interface.
|
||||
|
|
|
@ -13,7 +13,7 @@ Development version
|
|||
|
||||
2.0.0
|
||||
------
|
||||
- TBD
|
||||
- Drop backward compatibilities of 1.x.
|
||||
|
||||
1.17.0
|
||||
------
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
"""Dependency injector common catalogs unittests."""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
|
||||
class CatalogModuleBackwardCompatibility(unittest.TestCase):
|
||||
"""Backward compatibility test of catalog module."""
|
||||
|
||||
def test_import_catalog(self):
|
||||
"""Test that module `catalog` is the same as `catalogs`."""
|
||||
from dependency_injector import catalog
|
||||
from dependency_injector import catalogs
|
||||
|
||||
self.assertIs(catalog, catalogs)
|
|
@ -241,11 +241,6 @@ class DeclarativeCatalogTests(unittest.TestCase):
|
|||
|
||||
def test_get(self):
|
||||
"""Test getting of providers using get() method."""
|
||||
self.assertIs(CatalogB.get('p11'), CatalogB.p11)
|
||||
self.assertIs(CatalogB.get('p12'), CatalogB.p12)
|
||||
self.assertIs(CatalogB.get('p22'), CatalogB.p22)
|
||||
self.assertIs(CatalogB.get('p22'), CatalogB.p22)
|
||||
|
||||
self.assertIs(CatalogB.get_provider('p11'), CatalogB.p11)
|
||||
self.assertIs(CatalogB.get_provider('p12'), CatalogB.p12)
|
||||
self.assertIs(CatalogB.get_provider('p22'), CatalogB.p22)
|
||||
|
@ -264,12 +259,6 @@ class DeclarativeCatalogTests(unittest.TestCase):
|
|||
|
||||
def test_has(self):
|
||||
"""Test checks of providers availability in catalog."""
|
||||
self.assertTrue(CatalogB.has('p11'))
|
||||
self.assertTrue(CatalogB.has('p12'))
|
||||
self.assertTrue(CatalogB.has('p21'))
|
||||
self.assertTrue(CatalogB.has('p22'))
|
||||
self.assertFalse(CatalogB.has('undefined'))
|
||||
|
||||
self.assertTrue(CatalogB.has_provider('p11'))
|
||||
self.assertTrue(CatalogB.has_provider('p12'))
|
||||
self.assertTrue(CatalogB.has_provider('p21'))
|
||||
|
@ -293,10 +282,6 @@ class DeclarativeCatalogTests(unittest.TestCase):
|
|||
self.assertIn('p21', repr(CatalogB))
|
||||
self.assertIn('p22', repr(CatalogB))
|
||||
|
||||
def test_abstract_catalog_backward_compatibility(self):
|
||||
"""Test that di.AbstractCatalog is available."""
|
||||
self.assertIs(catalogs.DeclarativeCatalog, catalogs.AbstractCatalog)
|
||||
|
||||
|
||||
class TestCatalogWithProvidingCallbacks(unittest.TestCase):
|
||||
"""Catalog with providing callback tests."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user