diff --git a/examples/providers/callable_args.py b/examples/providers/callable_args.py index 9a854d5b..27229a6f 100644 --- a/examples/providers/callable_args.py +++ b/examples/providers/callable_args.py @@ -1,6 +1,6 @@ """`Callable` providers with positional arguments example.""" -from dependency_injector import providers +import dependency_injector.providers as providers # Creating even and odd filter providers: diff --git a/examples/providers/callable_delegation.py b/examples/providers/callable_delegation.py index 4a59e004..6a982ca6 100644 --- a/examples/providers/callable_delegation.py +++ b/examples/providers/callable_delegation.py @@ -1,8 +1,7 @@ """`Callable` providers delegation example.""" import sys - -from dependency_injector import providers +import dependency_injector.providers as providers # Creating some callable provider and few delegates of it: diff --git a/examples/providers/callable_kwargs.py b/examples/providers/callable_kwargs.py index 0880940a..01c1d4c8 100644 --- a/examples/providers/callable_kwargs.py +++ b/examples/providers/callable_kwargs.py @@ -1,8 +1,7 @@ """`Callable` providers with keyword arguments example.""" import passlib.hash - -from dependency_injector import providers +import dependency_injector.providers as providers # Password hasher and verifier providers (hash function could be changed diff --git a/examples/providers/custom_factory.py b/examples/providers/custom_factory.py index 7193fbaa..f4b4ec26 100644 --- a/examples/providers/custom_factory.py +++ b/examples/providers/custom_factory.py @@ -1,6 +1,6 @@ """Custom `Factory` example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/delegated_callable.py b/examples/providers/delegated_callable.py index c4ee9546..36e4639c 100644 --- a/examples/providers/delegated_callable.py +++ b/examples/providers/delegated_callable.py @@ -1,6 +1,6 @@ """`DelegatedCallable` providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers def command1(config): diff --git a/examples/providers/delegated_factory.py b/examples/providers/delegated_factory.py index 03f6801f..e5ab61b0 100644 --- a/examples/providers/delegated_factory.py +++ b/examples/providers/delegated_factory.py @@ -1,6 +1,6 @@ """`DelegatedFactory` providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/delegated_singleton.py b/examples/providers/delegated_singleton.py index 5e7a5d74..f5c85ea3 100644 --- a/examples/providers/delegated_singleton.py +++ b/examples/providers/delegated_singleton.py @@ -1,6 +1,6 @@ """`DelegatedSingleton` providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers # Some delegated singleton provider: diff --git a/examples/providers/external_dependency.py b/examples/providers/external_dependency.py index 1aedd140..a0c9e239 100644 --- a/examples/providers/external_dependency.py +++ b/examples/providers/external_dependency.py @@ -2,8 +2,7 @@ import sqlite3 import contextlib - -from dependency_injector import providers +import dependency_injector.providers as providers class UserService(object): diff --git a/examples/providers/factory.py b/examples/providers/factory.py index 1219bf0e..dbb25160 100644 --- a/examples/providers/factory.py +++ b/examples/providers/factory.py @@ -1,6 +1,6 @@ """`Factory` providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/factory_attribute_injections.py b/examples/providers/factory_attribute_injections.py index a99a152c..9f70d4f0 100644 --- a/examples/providers/factory_attribute_injections.py +++ b/examples/providers/factory_attribute_injections.py @@ -1,7 +1,7 @@ """`Factory` providers with attribute injections example.""" -from dependency_injector import providers -from dependency_injector import injections +import dependency_injector.providers as providers +import dependency_injector.injections as injections class User(object): diff --git a/examples/providers/factory_init_args.py b/examples/providers/factory_init_args.py index ed259474..4ceb61d7 100644 --- a/examples/providers/factory_init_args.py +++ b/examples/providers/factory_init_args.py @@ -1,6 +1,6 @@ """`Factory` providers with init positional injections example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/factory_init_injections_and_contexts.py b/examples/providers/factory_init_injections_and_contexts.py index 10f503d3..4fcbd4ca 100644 --- a/examples/providers/factory_init_injections_and_contexts.py +++ b/examples/providers/factory_init_injections_and_contexts.py @@ -1,6 +1,6 @@ """`Factory` providers with init injections priority example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/factory_init_kwargs.py b/examples/providers/factory_init_kwargs.py index 85ba59c7..2e991a4e 100644 --- a/examples/providers/factory_init_kwargs.py +++ b/examples/providers/factory_init_kwargs.py @@ -1,6 +1,6 @@ """`Factory` providers with init keyword injections example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/factory_method_injections.py b/examples/providers/factory_method_injections.py deleted file mode 100644 index 9ce68cb4..00000000 --- a/examples/providers/factory_method_injections.py +++ /dev/null @@ -1,60 +0,0 @@ -"""`Factory` providers with method injections example.""" - -from dependency_injector import providers -from dependency_injector import injections - - -class User(object): - """Example class User.""" - - def __init__(self): - """Initializer.""" - self.main_photo = None - self.credit_card = None - - def set_main_photo(self, photo): - """Set user's main photo.""" - self.main_photo = photo - - def set_credit_card(self, credit_card): - """Set user's credit card.""" - self.credit_card = credit_card - - -class Photo(object): - """Example class Photo.""" - - -class CreditCard(object): - """Example class CreditCard.""" - -# User, Photo and CreditCard factories: -credit_cards_factory = providers.Factory(CreditCard) -photos_factory = providers.Factory(Photo) -users_factory = providers.Factory(User, - injections.Method('set_main_photo', - photos_factory), - injections.Method('set_credit_card', - credit_cards_factory)) - -# Creating several User objects: -user1 = users_factory() -# Same as: user1 = User() -# user1.set_main_photo(Photo()) -# user1.set_credit_card(CreditCard()) -user2 = users_factory() -# Same as: user2 = User() -# user2.set_main_photo(Photo()) -# user2.set_credit_card(CreditCard()) - -# Making some asserts: -assert user1 is not user2 - -assert isinstance(user1.main_photo, Photo) -assert isinstance(user1.credit_card, CreditCard) - -assert isinstance(user2.main_photo, Photo) -assert isinstance(user2.credit_card, CreditCard) - -assert user1.main_photo is not user2.main_photo -assert user1.credit_card is not user2.credit_card diff --git a/examples/providers/factory_provided_type.py b/examples/providers/factory_provided_type.py index 506db636..5cdbe385 100644 --- a/examples/providers/factory_provided_type.py +++ b/examples/providers/factory_provided_type.py @@ -1,7 +1,7 @@ """`Factory` specialization for limitation to provided type example.""" -from dependency_injector import providers -from dependency_injector import errors +import dependency_injector.providers as providers +import dependency_injector.errors as errors class BaseService(object): diff --git a/examples/providers/overriding_simple.py b/examples/providers/overriding_simple.py index 4d99cf31..d68dd5f0 100644 --- a/examples/providers/overriding_simple.py +++ b/examples/providers/overriding_simple.py @@ -1,6 +1,6 @@ """Simple providers overriding example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/overriding_users_model.py b/examples/providers/overriding_users_model.py index 6fdc7fed..5e0760e0 100644 --- a/examples/providers/overriding_users_model.py +++ b/examples/providers/overriding_users_model.py @@ -1,6 +1,6 @@ """Overriding user's model example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class User(object): diff --git a/examples/providers/singleton.py b/examples/providers/singleton.py index 73b736ec..1e42ad9a 100644 --- a/examples/providers/singleton.py +++ b/examples/providers/singleton.py @@ -1,6 +1,6 @@ """`Singleton` providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class UserService(object): diff --git a/examples/providers/singleton_delegation.py b/examples/providers/singleton_delegation.py index f2342ad2..1b7e324c 100644 --- a/examples/providers/singleton_delegation.py +++ b/examples/providers/singleton_delegation.py @@ -1,6 +1,6 @@ """`Singleton` providers delegation example.""" -from dependency_injector import providers +import dependency_injector.providers as providers # Some singleton provider and few delegates of it: diff --git a/examples/providers/singleton_provided_type.py b/examples/providers/singleton_provided_type.py index b29e1f86..e6d4caa2 100644 --- a/examples/providers/singleton_provided_type.py +++ b/examples/providers/singleton_provided_type.py @@ -1,7 +1,7 @@ """`Singleton` specialization for limitation to provided type example.""" -from dependency_injector import providers -from dependency_injector import errors +import dependency_injector.providers as providers +import dependency_injector.errors as errors class BaseService(object): diff --git a/examples/providers/singleton_reseting.py b/examples/providers/singleton_reseting.py index 19c9b238..fa58bf4a 100644 --- a/examples/providers/singleton_reseting.py +++ b/examples/providers/singleton_reseting.py @@ -1,6 +1,6 @@ """`Singleton` providers resetting example.""" -from dependency_injector import providers +import dependency_injector.providers as providers class UserService(object): diff --git a/examples/providers/static.py b/examples/providers/static.py index 7fa5460b..fbfd32d2 100644 --- a/examples/providers/static.py +++ b/examples/providers/static.py @@ -1,6 +1,6 @@ """Static providers example.""" -from dependency_injector import providers +import dependency_injector.providers as providers # Provides class - `object`: