Update example docblocks

This commit is contained in:
Roman Mogilatov 2015-10-26 12:52:52 +02:00
parent 53f692a78c
commit 607e51e218
11 changed files with 37 additions and 36 deletions

View File

@ -91,16 +91,16 @@ Examples
"""Catalog of service providers."""
database = di.Singleton(sqlite3.connect, ':memory:')
""":type: () -> sqlite3.Connection"""
""":type: di.Provider -> sqlite3.Connection"""
users = di.Factory(UsersService,
db=database)
""":type: () -> UsersService"""
""":type: di.Provider -> UsersService"""
auth = di.Factory(AuthService,
db=database,
users_service=users)
""":type: () -> AuthService"""
""":type: di.Provider -> AuthService"""
# Retrieving catalog providers:

View File

@ -39,7 +39,7 @@ from .utils import ensure_is_catalog_bundle
from .errors import Error
VERSION = '0.10.2'
VERSION = '0.10.3'
__all__ = (

View File

@ -9,7 +9,7 @@ that is standard naming convention for attribute names in Python.
.. note::
It might be useful to add such ``""":type: (di.Provider) -> Object1"""``
It might be useful to add such ``""":type: di.Provider -> Object1"""``
docstrings just on the next line after provider's definition. It will
help code analyzing tools and IDE's to understand that variable above
contains some callable object, that returns particular instance as a

View File

@ -7,6 +7,10 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
0.10.3
------
- Update example docblocks.
0.10.2
------
- Fix bug with injecting entities that implement ``__getattr__``.

View File

@ -1,9 +1,6 @@
"""Config provider examples."""
from dependency_injector.catalog import AbstractCatalog
from dependency_injector.providers import Config
from dependency_injector.providers import Factory
from dependency_injector.injections import KwArg
import dependency_injector as di
class ObjectA(object):
@ -16,17 +13,17 @@ class ObjectA(object):
self.timezone = timezone
class Catalog(AbstractCatalog):
"""Catalog of dependency_injector providers."""
class Catalog(di.AbstractCatalog):
"""Catalog of providers."""
config = Config()
""":type: (dependency_injector.Config)"""
config = di.Config()
""":type: di.Config"""
object_a = Factory(ObjectA,
KwArg('fee', config.FEE),
KwArg('price', config.PRICE),
KwArg('timezone', config.GLOBAL.TIMEZONE))
""":type: (dependency_injector.Provider) -> ObjectA"""
object_a = di.Factory(ObjectA,
fee=config.FEE,
price=config.PRICE,
timezone=config.GLOBAL.TIMEZONE)
""":type: di.Provider -> ObjectA"""
# Setting config value and making some tests.

View File

@ -11,13 +11,13 @@ class Services(di.AbstractCatalog):
"""Example catalog of service providers."""
users = di.Factory(services.UsersService)
""":type: (di.Provider) -> services.UsersService"""
""":type: di.Provider -> services.UsersService"""
auth = di.Factory(services.AuthService)
""":type: (di.Provider) -> services.AuthService"""
""":type: di.Provider -> services.AuthService"""
photos = di.Factory(services.PhotosService)
""":type: (di.Provider) -> services.PhotosService"""
""":type: di.Provider -> services.PhotosService"""
# Declaring views catalog:
@ -27,12 +27,12 @@ class Views(di.AbstractCatalog):
auth = di.Factory(views.AuthView,
services=Services.Bundle(Services.users,
Services.auth))
""":type: (di.Provider) -> views.AuthView"""
""":type: di.Provider -> views.AuthView"""
photos = di.Factory(views.PhotosView,
services=Services.Bundle(Services.users,
Services.photos))
""":type: (di.Provider) -> views.PhotosView"""
""":type: di.Provider -> views.PhotosView"""
# Creating example views:

View File

@ -7,14 +7,14 @@ class CatalogA(di.AbstractCatalog):
"""Example catalog A."""
provider1 = di.Factory(object)
""":type: (di.Provider) -> object"""
""":type: di.Provider -> object"""
class CatalogB(CatalogA):
"""Example catalog B."""
provider2 = di.Singleton(object)
""":type: (di.Provider) -> object"""
""":type: di.Provider -> object"""
# Making some asserts for `providers` attribute:

View File

@ -16,18 +16,18 @@ class Catalog(di.AbstractCatalog):
object1_factory = di.Factory(Object1,
arg1=1,
arg2=2)
""":type: (di.Provider) -> Object1"""
""":type: di.Provider -> Object1"""
object2_factory = di.Factory(Object2,
object1=object1_factory)
""":type: (di.Provider) -> Object2"""
""":type: di.Provider -> Object2"""
class AnotherCatalog(di.AbstractCatalog):
"""Another providers catalog."""
object2_factory = di.Factory(ExtendedObject2)
""":type: (di.Provider) -> ExtendedObject2"""
""":type: di.Provider -> ExtendedObject2"""
# Overriding `Catalog` with `AnotherCatalog`:

View File

@ -16,11 +16,11 @@ class Catalog(di.AbstractCatalog):
object1_factory = di.Factory(Object1,
arg1=1,
arg2=2)
""":type: (di.Provider) -> Object1"""
""":type: di.Provider -> Object1"""
object2_factory = di.Factory(Object2,
object1=object1_factory)
""":type: (di.Provider) -> Object2"""
""":type: di.Provider -> Object2"""
# Overriding `Catalog` with `AnotherCatalog`:
@ -29,7 +29,7 @@ class AnotherCatalog(di.AbstractCatalog):
"""Another providers catalog."""
object2_factory = di.Factory(ExtendedObject2)
""":type: (di.Provider) -> ExtendedObject2"""
""":type: di.Provider -> ExtendedObject2"""
# Creating some objects using overridden catalog:

View File

@ -7,10 +7,10 @@ class Catalog(di.AbstractCatalog):
"""Providers catalog."""
factory1 = di.Factory(object)
""":type: (di.Provider) -> object"""
""":type: di.Provider -> object"""
factory2 = di.Factory(object)
""":type: (di.Provider) -> object"""
""":type: di.Provider -> object"""
# Creating some objects:
object1 = Catalog.factory1()

View File

@ -25,16 +25,16 @@ class Services(di.AbstractCatalog):
"""Catalog of service providers."""
database = di.Singleton(sqlite3.connect, ':memory:')
""":type: () -> sqlite3.Connection"""
""":type: di.Provider -> sqlite3.Connection"""
users = di.Factory(UsersService,
db=database)
""":type: () -> UsersService"""
""":type: di.Provider -> UsersService"""
auth = di.Factory(AuthService,
db=database,
users_service=users)
""":type: () -> AuthService"""
""":type: di.Provider -> AuthService"""
# Retrieving catalog providers: