diff --git a/dependency_injector/__init__.py b/dependency_injector/__init__.py index 019316f9..97e40afb 100644 --- a/dependency_injector/__init__.py +++ b/dependency_injector/__init__.py @@ -39,7 +39,7 @@ from .utils import ensure_is_catalog_bundle from .errors import Error -VERSION = '0.10.4' +VERSION = '0.10.5' __all__ = ( diff --git a/dependency_injector/catalog.py b/dependency_injector/catalog.py index 06718458..d3085678 100644 --- a/dependency_injector/catalog.py +++ b/dependency_injector/catalog.py @@ -9,6 +9,7 @@ from .utils import is_catalog from .utils import ensure_is_catalog_bundle +@six.python_2_unicode_compatible class CatalogBundle(object): """Bundle of catalog providers.""" @@ -58,11 +59,15 @@ class CatalogBundle(object): self._raise_undefined_provider_error(item) def __repr__(self): - """Return string representation of bundle.""" - return ''.format( - self.catalog, ', '.join(six.iterkeys(self.providers))) + """Return string representation of catalog bundle.""" + return '<{0}.{1}.Bundle({2})>'.format( + self.catalog.__module__, self.catalog.__name__, + ', '.join(six.iterkeys(self.providers))) + + __str__ = __repr__ +@six.python_2_unicode_compatible class CatalogMetaClass(type): """Catalog meta class.""" @@ -121,7 +126,9 @@ class CatalogMetaClass(type): def __repr__(cls): """Return string representation of the catalog class.""" - return '' + return '<{0}.{1}>'.format(cls.__module__, cls.__name__) + + __str__ = __repr__ @six.add_metaclass(CatalogMetaClass) diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index a0e5483e..f7aa28f3 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -7,6 +7,11 @@ that were made in every particular version. From version 0.7.6 *Dependency Injector* framework strictly follows `Semantic versioning`_ +0.10.5 +------ +- Add more representable implementation for ``di.AbstractCatalog`` and + ``di.AbstractCatalog.Bundle``. + 0.10.4 ------ - Remove VERSION file from MANIFEST.in. diff --git a/examples/catalogs/bundles/catalogs.py b/examples/catalogs/bundles/catalogs.py index 50ff6027..0b30db2d 100644 --- a/examples/catalogs/bundles/catalogs.py +++ b/examples/catalogs/bundles/catalogs.py @@ -39,6 +39,9 @@ class Views(di.AbstractCatalog): auth_view = Views.auth() photos_view = Views.photos() +print auth_view.services # prints: <__main__.Services.Bundle(users, auth)> +print photos_view.services # prints <__main__.Services.Bundle(photos, users)> + # Making some asserts: assert auth_view.services.users is Services.users assert auth_view.services.auth is Services.auth