mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Fix PEP257 D211 error
This commit is contained in:
parent
b7bab4938f
commit
8ab0cc5e0e
|
@ -71,7 +71,6 @@ Examples
|
|||
|
||||
|
||||
class ObjectA(object):
|
||||
|
||||
"""Example class ObjectA, that has dependency on database."""
|
||||
|
||||
def __init__(self, db):
|
||||
|
@ -80,7 +79,6 @@ Examples
|
|||
|
||||
|
||||
class ObjectB(object):
|
||||
|
||||
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
||||
|
||||
def __init__(self, a, db):
|
||||
|
@ -90,7 +88,6 @@ Examples
|
|||
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Catalog of providers."""
|
||||
|
||||
database = di.Singleton(sqlite3.Connection,
|
||||
|
|
|
@ -9,7 +9,6 @@ from .utils import is_catalog
|
|||
|
||||
|
||||
class CatalogMetaClass(type):
|
||||
|
||||
"""Providers catalog meta class."""
|
||||
|
||||
def __new__(mcs, class_name, bases, attributes):
|
||||
|
@ -35,7 +34,6 @@ class CatalogMetaClass(type):
|
|||
|
||||
@six.add_metaclass(CatalogMetaClass)
|
||||
class AbstractCatalog(object):
|
||||
|
||||
"""Abstract providers catalog.
|
||||
|
||||
:type providers: dict[str, dependency_injector.Provider]
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
|
||||
class Error(Exception):
|
||||
|
||||
"""Base error."""
|
||||
|
|
|
@ -18,7 +18,6 @@ else: # pragma: no cover
|
|||
|
||||
|
||||
class Injection(object):
|
||||
|
||||
"""Base injection class."""
|
||||
|
||||
__IS_INJECTION__ = True
|
||||
|
@ -38,21 +37,18 @@ class Injection(object):
|
|||
|
||||
|
||||
class KwArg(Injection):
|
||||
|
||||
"""Keyword argument injection."""
|
||||
|
||||
__IS_KWARG_INJECTION__ = True
|
||||
|
||||
|
||||
class Attribute(Injection):
|
||||
|
||||
"""Attribute injection."""
|
||||
|
||||
__IS_ATTRIBUTE_INJECTION__ = True
|
||||
|
||||
|
||||
class Method(Injection):
|
||||
|
||||
"""Method injection."""
|
||||
|
||||
__IS_METHOD_INJECTION__ = True
|
||||
|
|
|
@ -15,7 +15,6 @@ from .errors import Error
|
|||
|
||||
|
||||
class Provider(object):
|
||||
|
||||
"""Base provider class."""
|
||||
|
||||
__IS_PROVIDER__ = True
|
||||
|
@ -76,7 +75,6 @@ class Provider(object):
|
|||
|
||||
|
||||
class Delegate(Provider):
|
||||
|
||||
"""Provider's delegate."""
|
||||
|
||||
__slots__ = ('delegated',)
|
||||
|
@ -95,7 +93,6 @@ class Delegate(Provider):
|
|||
|
||||
|
||||
class Factory(Provider):
|
||||
|
||||
"""Factory provider.
|
||||
|
||||
Factory provider creates new instance of specified class on every call.
|
||||
|
@ -142,7 +139,6 @@ class Factory(Provider):
|
|||
|
||||
|
||||
class Singleton(Provider):
|
||||
|
||||
"""Singleton provider.
|
||||
|
||||
Singleton provider will create instance once and return it on every call.
|
||||
|
@ -169,7 +165,6 @@ class Singleton(Provider):
|
|||
|
||||
|
||||
class ExternalDependency(Provider):
|
||||
|
||||
"""External dependency provider.
|
||||
|
||||
Those provider is used when dependency obviously have to be overridden by
|
||||
|
@ -205,7 +200,6 @@ class ExternalDependency(Provider):
|
|||
|
||||
|
||||
class StaticProvider(Provider):
|
||||
|
||||
"""Static provider.
|
||||
|
||||
Static provider is base implementation that provides exactly the same as
|
||||
|
@ -225,27 +219,22 @@ class StaticProvider(Provider):
|
|||
|
||||
|
||||
class Class(StaticProvider):
|
||||
|
||||
"""Class provider provides class."""
|
||||
|
||||
|
||||
class Object(StaticProvider):
|
||||
|
||||
"""Object provider provides object."""
|
||||
|
||||
|
||||
class Function(StaticProvider):
|
||||
|
||||
"""Function provider provides function."""
|
||||
|
||||
|
||||
class Value(StaticProvider):
|
||||
|
||||
"""Value provider provides value."""
|
||||
|
||||
|
||||
class Callable(Provider):
|
||||
|
||||
"""Callable provider.
|
||||
|
||||
Callable provider provides callable that is called on every provider call
|
||||
|
@ -270,7 +259,6 @@ class Callable(Provider):
|
|||
|
||||
|
||||
class Config(Provider):
|
||||
|
||||
"""Config provider.
|
||||
|
||||
Config provider provides dict values. Also config provider creates
|
||||
|
@ -309,7 +297,6 @@ class Config(Provider):
|
|||
|
||||
|
||||
class ChildConfig(Provider):
|
||||
|
||||
"""Child config provider.
|
||||
|
||||
Child config provide an value from the root config object according to
|
||||
|
|
|
@ -7,7 +7,6 @@ from dependency_injector.injections import KwArg
|
|||
|
||||
|
||||
class ObjectA(object):
|
||||
|
||||
"""Example class ObjectA, that has dependencies on some setting values."""
|
||||
|
||||
def __init__(self, fee, price, timezone):
|
||||
|
@ -18,7 +17,6 @@ class ObjectA(object):
|
|||
|
||||
|
||||
class Catalog(AbstractCatalog):
|
||||
|
||||
"""Catalog of dependency_injector providers."""
|
||||
|
||||
config = Config()
|
||||
|
|
|
@ -18,7 +18,6 @@ app = flask.Flask(__name__)
|
|||
@di.inject(database=database)
|
||||
@di.inject(some_setting=777)
|
||||
class HelloView(flask.views.View):
|
||||
|
||||
"""Example flask class-based view."""
|
||||
|
||||
def __init__(self, database, some_setting):
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class CatalogA(di.AbstractCatalog):
|
||||
|
||||
"""Example catalog A."""
|
||||
|
||||
provider1 = di.Factory(object)
|
||||
|
@ -12,7 +11,6 @@ class CatalogA(di.AbstractCatalog):
|
|||
|
||||
|
||||
class CatalogB(CatalogA):
|
||||
|
||||
"""Example catalog B."""
|
||||
|
||||
provider2 = di.Singleton(object)
|
||||
|
|
|
@ -11,7 +11,6 @@ ExtendedObject2 = collections.namedtuple('ExtendedObject2', [])
|
|||
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Providers catalog."""
|
||||
|
||||
object1_factory = di.Factory(Object1,
|
||||
|
@ -25,7 +24,6 @@ class Catalog(di.AbstractCatalog):
|
|||
|
||||
|
||||
class AnotherCatalog(di.AbstractCatalog):
|
||||
|
||||
"""Another providers catalog."""
|
||||
|
||||
object2_factory = di.Factory(ExtendedObject2)
|
||||
|
|
|
@ -11,7 +11,6 @@ ExtendedObject2 = collections.namedtuple('ExtendedObject2', [])
|
|||
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Providers catalog."""
|
||||
|
||||
object1_factory = di.Factory(Object1,
|
||||
|
@ -27,7 +26,6 @@ class Catalog(di.AbstractCatalog):
|
|||
# Overriding `Catalog` with `AnotherCatalog`:
|
||||
@di.override(Catalog)
|
||||
class AnotherCatalog(di.AbstractCatalog):
|
||||
|
||||
"""Another providers catalog."""
|
||||
|
||||
object2_factory = di.Factory(ExtendedObject2)
|
||||
|
|
|
@ -10,7 +10,6 @@ Object2 = collections.namedtuple('Object2', ['object1'])
|
|||
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Providers catalog."""
|
||||
|
||||
object1_factory = di.Factory(Object1,
|
||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class ObjectA(object):
|
||||
|
||||
"""Example class ObjectA, that has dependency on database."""
|
||||
|
||||
def __init__(self, db):
|
||||
|
@ -14,7 +13,6 @@ class ObjectA(object):
|
|||
|
||||
|
||||
class ObjectB(object):
|
||||
|
||||
"""Example class ObjectB, that has dependencies on ObjectA and database."""
|
||||
|
||||
def __init__(self, a, db):
|
||||
|
@ -24,7 +22,6 @@ class ObjectB(object):
|
|||
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Catalog of providers."""
|
||||
|
||||
database = di.Singleton(sqlite3.Connection,
|
||||
|
|
|
@ -4,12 +4,10 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
|
||||
class UsersFactory(di.Provider):
|
||||
|
||||
"""Example users factory."""
|
||||
|
||||
__slots__ = ('_factory',)
|
||||
|
|
|
@ -6,7 +6,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class UserService(object):
|
||||
|
||||
"""Example class UserService.
|
||||
|
||||
UserService has dependency on DBAPI 2.0 database connection.
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
# Factory provider creates new instance of specified class on every call.
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -14,12 +13,10 @@ class User(object):
|
|||
|
||||
|
||||
class Photo(object):
|
||||
|
||||
"""Example class Photo."""
|
||||
|
||||
|
||||
class CreditCard(object):
|
||||
|
||||
"""Example class CreditCard."""
|
||||
|
||||
# User, Photo and CreditCard factories:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
def __init__(self, photos_factory):
|
||||
|
@ -25,7 +24,6 @@ class User(object):
|
|||
|
||||
|
||||
class Photo(object):
|
||||
|
||||
"""Example class Photo."""
|
||||
|
||||
# User and Photo factories:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
def __init__(self, main_photo):
|
||||
|
@ -14,7 +13,6 @@ class User(object):
|
|||
|
||||
|
||||
class Photo(object):
|
||||
|
||||
"""Example class Photo."""
|
||||
|
||||
# User and Photo factories:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User.
|
||||
|
||||
Class User has to be provided with user id.
|
||||
|
@ -24,12 +23,10 @@ class User(object):
|
|||
|
||||
|
||||
class Photo(object):
|
||||
|
||||
"""Example class Photo."""
|
||||
|
||||
|
||||
class CreditCard(object):
|
||||
|
||||
"""Example class CreditCard."""
|
||||
|
||||
# User, Photo and CreditCard factories:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -22,12 +21,10 @@ class User(object):
|
|||
|
||||
|
||||
class Photo(object):
|
||||
|
||||
"""Example class Photo."""
|
||||
|
||||
|
||||
class CreditCard(object):
|
||||
|
||||
"""Example class CreditCard."""
|
||||
|
||||
# User, Photo and CreditCard factories:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
# Users factory:
|
||||
|
@ -21,7 +20,6 @@ assert isinstance(user1, User) and isinstance(user2, User)
|
|||
|
||||
# Extending User:
|
||||
class SuperUser(User):
|
||||
|
||||
"""Example class SuperUser."""
|
||||
|
||||
# Overriding users factory:
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class User(object):
|
||||
|
||||
"""Example class User."""
|
||||
|
||||
def __init__(self, id, password):
|
||||
|
@ -15,7 +14,6 @@ class User(object):
|
|||
|
||||
|
||||
class UserService(object):
|
||||
|
||||
"""Example class UserService."""
|
||||
|
||||
def __init__(self, user_cls):
|
||||
|
@ -50,7 +48,6 @@ assert user1 is not user2
|
|||
|
||||
|
||||
class ExtendedUser(User):
|
||||
|
||||
"""Example class ExtendedUser."""
|
||||
|
||||
def __init__(self, id, password, first_name=None, last_name=None,
|
||||
|
@ -63,7 +60,6 @@ class ExtendedUser(User):
|
|||
|
||||
|
||||
class ExtendedUserService(UserService):
|
||||
|
||||
"""Example class ExtendedUserService."""
|
||||
|
||||
def get_by_id(self, id):
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class UserService(object):
|
||||
|
||||
"""Example class UserService."""
|
||||
|
||||
# Singleton provider creates new instance of specified class on first call and
|
||||
|
|
|
@ -4,7 +4,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class UserService(object):
|
||||
|
||||
"""Example class UserService."""
|
||||
|
||||
# Users service singleton provider:
|
||||
|
|
|
@ -5,25 +5,21 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class CatalogsInheritanceTests(unittest.TestCase):
|
||||
|
||||
"""Catalogs inheritance tests."""
|
||||
|
||||
class CatalogA(di.AbstractCatalog):
|
||||
|
||||
"""Test catalog A."""
|
||||
|
||||
p11 = di.Provider()
|
||||
p12 = di.Provider()
|
||||
|
||||
class CatalogB(CatalogA):
|
||||
|
||||
"""Test catalog B."""
|
||||
|
||||
p21 = di.Provider()
|
||||
p22 = di.Provider()
|
||||
|
||||
class CatalogC(CatalogB):
|
||||
|
||||
"""Test catalog C."""
|
||||
|
||||
p31 = di.Provider()
|
||||
|
@ -73,11 +69,9 @@ class CatalogsInheritanceTests(unittest.TestCase):
|
|||
|
||||
|
||||
class CatalogTests(unittest.TestCase):
|
||||
|
||||
"""Catalog test cases."""
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Test catalog."""
|
||||
|
||||
obj = di.Object(object())
|
||||
|
@ -100,11 +94,9 @@ class CatalogTests(unittest.TestCase):
|
|||
|
||||
|
||||
class OverrideTests(unittest.TestCase):
|
||||
|
||||
"""Override decorator test cases."""
|
||||
|
||||
class Catalog(di.AbstractCatalog):
|
||||
|
||||
"""Test catalog."""
|
||||
|
||||
obj = di.Object(object())
|
||||
|
@ -114,7 +106,6 @@ class OverrideTests(unittest.TestCase):
|
|||
"""Test catalog overriding with another catalog."""
|
||||
@di.override(self.Catalog)
|
||||
class OverridingCatalog(self.Catalog):
|
||||
|
||||
"""Overriding catalog."""
|
||||
|
||||
obj = di.Value(1)
|
||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class InjectionTests(unittest.TestCase):
|
||||
|
||||
"""Injection test cases."""
|
||||
|
||||
def test_init(self):
|
||||
|
@ -26,7 +25,6 @@ class InjectionTests(unittest.TestCase):
|
|||
|
||||
|
||||
class KwArgTests(unittest.TestCase):
|
||||
|
||||
"""Keyword arg injection test cases."""
|
||||
|
||||
def test_init(self):
|
||||
|
@ -37,7 +35,6 @@ class KwArgTests(unittest.TestCase):
|
|||
|
||||
|
||||
class AttributeTests(unittest.TestCase):
|
||||
|
||||
"""Attribute injection test cases."""
|
||||
|
||||
def test_init(self):
|
||||
|
@ -48,7 +45,6 @@ class AttributeTests(unittest.TestCase):
|
|||
|
||||
|
||||
class MethodTests(unittest.TestCase):
|
||||
|
||||
"""Method injection test cases."""
|
||||
|
||||
def test_init(self):
|
||||
|
@ -59,7 +55,6 @@ class MethodTests(unittest.TestCase):
|
|||
|
||||
|
||||
class InjectTests(unittest.TestCase):
|
||||
|
||||
"""Inject decorator test cases."""
|
||||
|
||||
def test_decorated(self):
|
||||
|
@ -155,7 +150,6 @@ class InjectTests(unittest.TestCase):
|
|||
def test_decorate_class_method(self):
|
||||
"""Test `inject()` decorator with class method."""
|
||||
class Test(object):
|
||||
|
||||
"""Test class."""
|
||||
|
||||
@di.inject(arg1=123)
|
||||
|
@ -175,7 +169,6 @@ class InjectTests(unittest.TestCase):
|
|||
@di.inject(arg1=123)
|
||||
@di.inject(arg2=456)
|
||||
class Test(object):
|
||||
|
||||
"""Test class."""
|
||||
|
||||
def __init__(self, arg1, arg2):
|
||||
|
@ -193,5 +186,4 @@ class InjectTests(unittest.TestCase):
|
|||
with self.assertRaises(di.Error):
|
||||
@di.inject(arg1=123)
|
||||
class Test(object):
|
||||
|
||||
"""Test class."""
|
||||
|
|
|
@ -5,7 +5,6 @@ import dependency_injector as di
|
|||
|
||||
|
||||
class ProviderTests(unittest.TestCase):
|
||||
|
||||
"""Provider test cases."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -106,7 +105,6 @@ class ProviderTests(unittest.TestCase):
|
|||
|
||||
|
||||
class DelegateTests(unittest.TestCase):
|
||||
|
||||
"""Delegate test cases."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -132,11 +130,9 @@ class DelegateTests(unittest.TestCase):
|
|||
|
||||
|
||||
class FactoryTests(unittest.TestCase):
|
||||
|
||||
"""Factory test cases."""
|
||||
|
||||
class Example(object):
|
||||
|
||||
"""Example class for Factory provider tests."""
|
||||
|
||||
def __init__(self, init_arg1=None, init_arg2=None):
|
||||
|
@ -317,7 +313,6 @@ class FactoryTests(unittest.TestCase):
|
|||
|
||||
|
||||
class SingletonTests(unittest.TestCase):
|
||||
|
||||
"""Singleton test cases."""
|
||||
|
||||
def test_call(self):
|
||||
|
@ -347,7 +342,6 @@ class SingletonTests(unittest.TestCase):
|
|||
|
||||
|
||||
class ExternalDependencyTests(unittest.TestCase):
|
||||
|
||||
"""ExternalDependency test cases."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -378,7 +372,6 @@ class ExternalDependencyTests(unittest.TestCase):
|
|||
|
||||
|
||||
class StaticProvidersTests(unittest.TestCase):
|
||||
|
||||
"""Static providers test cases."""
|
||||
|
||||
def test_is_provider(self):
|
||||
|
@ -433,7 +426,6 @@ class StaticProvidersTests(unittest.TestCase):
|
|||
|
||||
|
||||
class CallableTests(unittest.TestCase):
|
||||
|
||||
"""Callable test cases."""
|
||||
|
||||
def example(self, arg1, arg2, arg3):
|
||||
|
@ -485,7 +477,6 @@ class CallableTests(unittest.TestCase):
|
|||
|
||||
|
||||
class ConfigTests(unittest.TestCase):
|
||||
|
||||
"""Config test cases."""
|
||||
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user