mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Drop catalogs name attribute
This commit is contained in:
parent
ab7cd86146
commit
7d33e0e3a2
|
@ -40,7 +40,6 @@ class DeclarativeCatalogMetaClass(type):
|
|||
else:
|
||||
cls._catalog = DynamicCatalog()
|
||||
|
||||
cls._catalog.name = '.'.join((cls.__module__, cls.__name__))
|
||||
cls._catalog.bind_providers(dict(providers))
|
||||
|
||||
cls._cls_providers = dict(cls_providers)
|
||||
|
@ -48,16 +47,6 @@ class DeclarativeCatalogMetaClass(type):
|
|||
|
||||
return cls
|
||||
|
||||
@property
|
||||
def name(cls):
|
||||
"""Read-only property that represents catalog's name.
|
||||
|
||||
Catalog's name is catalog's module + catalog's class name.
|
||||
|
||||
:type: str
|
||||
"""
|
||||
return cls._catalog.name
|
||||
|
||||
@property
|
||||
def providers(cls):
|
||||
"""Read-only dictionary of all providers.
|
||||
|
@ -159,7 +148,7 @@ class DeclarativeCatalogMetaClass(type):
|
|||
|
||||
:rtype: str
|
||||
"""
|
||||
return '<{0}({1})>'.format(cls.name,
|
||||
return '<{0}({1})>'.format('.'.join((cls.__module__, cls.__name__)),
|
||||
', '.join(six.iterkeys(cls.providers)))
|
||||
|
||||
__str__ = __repr__
|
||||
|
@ -202,16 +191,6 @@ class DeclarativeCatalog(object):
|
|||
|
||||
__IS_CATALOG__ = True
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Read-only property that represents catalog's name.
|
||||
|
||||
Catalog's name is catalog's module + catalog's class name.
|
||||
|
||||
:rtype: str
|
||||
"""
|
||||
return self.__class__.name
|
||||
|
||||
@property
|
||||
def providers(self):
|
||||
"""Read-only dictionary of all providers.
|
||||
|
|
|
@ -30,14 +30,6 @@ class DynamicCatalog(object):
|
|||
|
||||
users_service = services.users()
|
||||
|
||||
.. py:attribute:: name
|
||||
|
||||
Catalog's name.
|
||||
|
||||
By default, it is catalog's module + catalog's class name.
|
||||
|
||||
:type: str
|
||||
|
||||
.. py:attribute:: providers
|
||||
|
||||
Dictionary of all providers.
|
||||
|
@ -63,7 +55,7 @@ class DynamicCatalog(object):
|
|||
provider_type = None
|
||||
|
||||
__IS_CATALOG__ = True
|
||||
__slots__ = ('name', 'providers', 'provider_names', 'overridden_by')
|
||||
__slots__ = ('providers', 'provider_names', 'overridden_by')
|
||||
|
||||
def __init__(self, **providers):
|
||||
"""Initializer.
|
||||
|
@ -72,8 +64,6 @@ class DynamicCatalog(object):
|
|||
:type providers:
|
||||
dict[str, :py:class:`dependency_injector.providers.Provider`]
|
||||
"""
|
||||
self.name = '.'.join((self.__class__.__module__,
|
||||
self.__class__.__name__))
|
||||
self.providers = dict()
|
||||
self.provider_names = dict()
|
||||
self.overridden_by = tuple()
|
||||
|
@ -312,7 +302,8 @@ class DynamicCatalog(object):
|
|||
|
||||
:rtype: str
|
||||
"""
|
||||
return '<{0}({1})>'.format(self.name,
|
||||
return '<{0}({1})>'.format('.'.join((self.__class__.__module__,
|
||||
self.__class__.__name__)),
|
||||
', '.join(six.iterkeys(self.providers)))
|
||||
|
||||
__str__ = __repr__
|
||||
|
|
|
@ -24,6 +24,7 @@ Development version
|
|||
- ``Config``
|
||||
- Drop method injections.
|
||||
- Drop catalog bundles.
|
||||
- Drop catalog's ``name`` attribute.
|
||||
- Drop backward compatibilities of 1.x.
|
||||
|
||||
1.17.0
|
||||
|
|
|
@ -429,8 +429,6 @@ class InstantiationTests(unittest.TestCase):
|
|||
|
||||
def test_access_instance_attributes(self):
|
||||
"""Test accessing declarative catalog instance attributes."""
|
||||
self.assertEqual(self.catalog.name,
|
||||
CatalogA.name)
|
||||
self.assertEqual(self.catalog.providers,
|
||||
CatalogA.providers)
|
||||
self.assertEqual(self.catalog.cls_providers,
|
||||
|
|
|
@ -19,7 +19,6 @@ class DynamicCatalogTests(unittest.TestCase):
|
|||
"""Set test environment up."""
|
||||
self.catalog = catalogs.DynamicCatalog(p1=providers.Provider(),
|
||||
p2=providers.Provider())
|
||||
self.catalog.name = 'TestCatalog'
|
||||
|
||||
def test_providers(self):
|
||||
"""Test `di.DeclarativeCatalog.inherited_providers` contents."""
|
||||
|
@ -214,6 +213,9 @@ class DynamicCatalogTests(unittest.TestCase):
|
|||
|
||||
def test_repr(self):
|
||||
"""Test catalog representation."""
|
||||
self.assertIn('TestCatalog', repr(self.catalog))
|
||||
self.assertIn('p1', repr(self.catalog))
|
||||
self.assertIn('p2', repr(self.catalog))
|
||||
representation = repr(self.catalog)
|
||||
|
||||
self.assertIn('dependency_injector.catalogs.dynamic.DynamicCatalog',
|
||||
representation)
|
||||
self.assertIn('p1', representation)
|
||||
self.assertIn('p2', representation)
|
||||
|
|
Loading…
Reference in New Issue
Block a user