@@ -28,10 +28,10 @@ if sys.version_info[:2] >= (3, 6):
28
28
from .wiring import wire, unwire
29
29
else :
30
30
def wire (*args , **kwargs ):
31
- raise NotImplementedError (' Wiring requires Python 3.6 or above' )
31
+ raise NotImplementedError (" Wiring requires Python 3.6 or above" )
32
32
33
33
def unwire (*args , **kwargs ):
34
- raise NotImplementedError (' Wiring requires Python 3.6 or above' )
34
+ raise NotImplementedError (" Wiring requires Python 3.6 or above" )
35
35
36
36
if sys.version_info[:2 ] == (3 , 5 ):
37
37
warnings.warn(
@@ -137,17 +137,17 @@ class DynamicContainer(Container):
137
137
If value of attribute is provider, it will be added into providers
138
138
dictionary.
139
139
140
- :param name: Attribute's name
140
+ :param name: Attribute name
141
141
:type name: object
142
142
143
- :param value: Attribute's value
143
+ :param value: Attribute value
144
144
:type value: object
145
145
146
146
:rtype: None
147
147
"""
148
148
if isinstance (value, providers.Provider) \
149
149
and not isinstance (value, providers.Self) \
150
- and name != ' parent' :
150
+ and name != " parent" :
151
151
_check_provider_type(self , value)
152
152
153
153
self .providers[name] = value
@@ -163,7 +163,7 @@ class DynamicContainer(Container):
163
163
If value of attribute is provider, it will be deleted from providers
164
164
dictionary.
165
165
166
- :param name: Attribute's name
166
+ :param name: Attribute name
167
167
:type name: object
168
168
169
169
:rtype: None
@@ -229,8 +229,8 @@ class DynamicContainer(Container):
229
229
:rtype: None
230
230
"""
231
231
if overriding is self :
232
- raise errors.Error(' Container {0} could not be overridden '
233
- ' with itself' .format(self ))
232
+ raise errors.Error(" Container {0} could not be overridden "
233
+ " with itself" .format(self ))
234
234
235
235
self .overridden += (overriding,)
236
236
@@ -262,7 +262,7 @@ class DynamicContainer(Container):
262
262
:rtype: None
263
263
"""
264
264
if not self .overridden:
265
- raise errors.Error(' Container {0} is not overridden' .format(self ))
265
+ raise errors.Error(" Container {0} is not overridden" .format(self ))
266
266
267
267
self .overridden = self .overridden[:- 1 ]
268
268
@@ -364,7 +364,7 @@ class DynamicContainer(Container):
364
364
while any (resource.initialized for resource in resources):
365
365
resources_to_shutdown = list (_independent_resources(resources))
366
366
if not resources_to_shutdown:
367
- raise RuntimeError (' Unable to resolve resources shutdown order' )
367
+ raise RuntimeError (" Unable to resolve resources shutdown order" )
368
368
futures = []
369
369
for resource in resources_to_shutdown:
370
370
result = resource.shutdown()
@@ -376,7 +376,7 @@ class DynamicContainer(Container):
376
376
while any (resource.initialized for resource in resources):
377
377
resources_to_shutdown = list (_independent_resources(resources))
378
378
if not resources_to_shutdown:
379
- raise RuntimeError (' Unable to resolve resources shutdown order' )
379
+ raise RuntimeError (" Unable to resolve resources shutdown order" )
380
380
for resource in resources_to_shutdown:
381
381
resource.shutdown()
382
382
@@ -393,7 +393,7 @@ class DynamicContainer(Container):
393
393
config.load()
394
394
395
395
def apply_container_providers_overridings (self ):
396
- """ Apply container providers' overridings."""
396
+ """ Apply container providers overridings."""
397
397
for provider in self .traverse(types = [providers.Container]):
398
398
provider.apply_overridings()
399
399
@@ -419,12 +419,12 @@ class DynamicContainer(Container):
419
419
420
420
container_name = self .parent_name if self .parent_name else self .__class__.__name__
421
421
undefined_names = [
422
- f' " {dependency.parent_name if dependency.parent_name else dependency}" '
422
+ f" \" {dependency.parent_name if dependency.parent_name else dependency}\" "
423
423
for dependency in undefined
424
424
]
425
425
raise errors.Error(
426
- f' Container "{container_name}" has undefined dependencies: '
427
- f' {", " .join(undefined_names)}' ,
426
+ f" Container \ " {container_name}\ " has undefined dependencies: "
427
+ f" {', ' .join(undefined_names)}" ,
428
428
)
429
429
430
430
def from_schema (self , schema ):
@@ -441,9 +441,9 @@ class DynamicContainer(Container):
441
441
"""
442
442
if yaml is None :
443
443
raise errors.Error(
444
- ' Unable to load yaml schema - PyYAML is not installed. '
445
- ' Install PyYAML or install Dependency Injector with yaml extras: '
446
- ' " pip install dependency-injector[yaml]" '
444
+ " Unable to load yaml schema - PyYAML is not installed. "
445
+ " Install PyYAML or install Dependency Injector with yaml extras: "
446
+ " \" pip install dependency-injector[yaml]\" "
447
447
)
448
448
449
449
if loader is None :
@@ -466,7 +466,7 @@ class DynamicContainer(Container):
466
466
if container_provider is provider:
467
467
return provider_name
468
468
else :
469
- raise errors.Error(f' Can not resolve name for provider "{provider}" ' )
469
+ raise errors.Error(f" Can not resolve name for provider \ " {provider}\" " )
470
470
471
471
@property
472
472
def parent_name (self ):
@@ -525,11 +525,11 @@ class DeclarativeContainerMetaClass(type):
525
525
" instead got {0}" .format(wiring_config)
526
526
)
527
527
528
- attributes[' containers' ] = containers
529
- attributes[' inherited_providers' ] = inherited_providers
530
- attributes[' cls_providers' ] = cls_providers
531
- attributes[' providers' ] = all_providers
532
- attributes[' wiring_config' ] = wiring_config
528
+ attributes[" containers" ] = containers
529
+ attributes[" inherited_providers" ] = inherited_providers
530
+ attributes[" cls_providers" ] = cls_providers
531
+ attributes[" providers" ] = all_providers
532
+ attributes[" wiring_config" ] = wiring_config
533
533
534
534
cls = < type > type .__new__ (mcs, class_name, bases, attributes)
535
535
@@ -551,15 +551,15 @@ class DeclarativeContainerMetaClass(type):
551
551
If value of attribute is provider, it will be added into providers
552
552
dictionary.
553
553
554
- :param name: Attribute's name
554
+ :param name: Attribute name
555
555
:type name: object
556
556
557
- :param value: Attribute's value
557
+ :param value: Attribute value
558
558
:type value: object
559
559
560
560
:rtype: None
561
561
"""
562
- if isinstance (value, providers.Provider) and name != ' __self__' :
562
+ if isinstance (value, providers.Provider) and name != " __self__" :
563
563
_check_provider_type(cls , value)
564
564
565
565
if isinstance (value, providers.CHILD_PROVIDERS):
@@ -575,7 +575,7 @@ class DeclarativeContainerMetaClass(type):
575
575
If value of attribute is provider, it will be deleted from providers
576
576
dictionary.
577
577
578
- :param name: Attribute's name
578
+ :param name: Attribute name
579
579
:type name: object
580
580
581
581
:rtype: None
@@ -611,7 +611,7 @@ class DeclarativeContainerMetaClass(type):
611
611
if container_provider is provider:
612
612
return provider_name
613
613
else :
614
- raise errors.Error(f' Can not resolve name for provider "{provider}" ' )
614
+ raise errors.Error(f" Can not resolve name for provider \ " {provider}\" " )
615
615
616
616
@property
617
617
def parent_name (cls ):
@@ -628,9 +628,9 @@ class DeclarativeContainerMetaClass(type):
628
628
continue
629
629
630
630
if self is not None and value is not self :
631
- raise errors.Error(' Container can have only one "Self" provider' )
631
+ raise errors.Error(" Container can have only one \ " Self\ " provider" )
632
632
633
- if name != ' __self__' :
633
+ if name != " __self__" :
634
634
alt_names.append(name)
635
635
636
636
self = value
@@ -727,8 +727,8 @@ class DeclarativeContainer(Container):
727
727
container.wiring_config = copy_module.deepcopy(cls .wiring_config)
728
728
container.declarative_parent = cls
729
729
730
- copied_providers = providers.deepcopy({ ** cls .providers, ** {' @@self@@' : cls .__self__}})
731
- copied_self = copied_providers.pop(' @@self@@' )
730
+ copied_providers = providers.deepcopy({ ** cls .providers, ** {" @@self@@" : cls .__self__}})
731
+ copied_self = copied_providers.pop(" @@self@@" )
732
732
copied_self.set_container(container)
733
733
734
734
container.__self__ = copied_self
@@ -762,8 +762,8 @@ class DeclarativeContainer(Container):
762
762
:rtype: None
763
763
"""
764
764
if issubclass (cls , overriding):
765
- raise errors.Error(' Container {0} could not be overridden '
766
- ' with itself or its subclasses' .format(cls ))
765
+ raise errors.Error(" Container {0} could not be overridden "
766
+ " with itself or its subclasses" .format(cls ))
767
767
768
768
cls .overridden += (overriding,)
769
769
@@ -780,7 +780,7 @@ class DeclarativeContainer(Container):
780
780
:rtype: None
781
781
"""
782
782
if not cls .overridden:
783
- raise errors.Error(' Container {0} is not overridden' .format(cls ))
783
+ raise errors.Error(" Container {0} is not overridden" .format(cls ))
784
784
785
785
cls .overridden = cls .overridden[:- 1 ]
786
786
@@ -833,7 +833,7 @@ def override(object container):
833
833
container.
834
834
:type container: :py:class:`DeclarativeContainer`
835
835
836
- :return: Declarative container's overriding decorator.
836
+ :return: Declarative container overriding decorator.
837
837
:rtype: callable(:py:class:`DeclarativeContainer`)
838
838
"""
839
839
def _decorator (object overriding_container ):
@@ -853,7 +853,7 @@ def copy(object base_container):
853
853
:param base_container: Container that should be copied by decorated container.
854
854
:type base_container: :py:class:`DeclarativeContainer`
855
855
856
- :return: Declarative container's copying decorator.
856
+ :return: Declarative container copying decorator.
857
857
:rtype: callable(:py:class:`DeclarativeContainer`)
858
858
"""
859
859
def _get_memo_for_matching_names (new_providers , base_providers ):
@@ -864,7 +864,7 @@ def copy(object base_container):
864
864
source_provider = base_providers[new_provider_name]
865
865
memo[id (source_provider)] = new_provider
866
866
867
- if hasattr (new_provider, ' providers' ) and hasattr (source_provider, ' providers' ):
867
+ if hasattr (new_provider, " providers" ) and hasattr (source_provider, " providers" ):
868
868
sub_memo = _get_memo_for_matching_names(new_provider.providers, source_provider.providers)
869
869
memo.update(sub_memo)
870
870
return memo
@@ -892,13 +892,13 @@ cpdef bint is_container(object instance):
892
892
893
893
:rtype: bool
894
894
"""
895
- return getattr (instance, ' __IS_CONTAINER__' , False ) is True
895
+ return getattr (instance, " __IS_CONTAINER__" , False ) is True
896
896
897
897
898
898
cpdef object _check_provider_type(object container, object provider):
899
899
if not isinstance (provider, container.provider_type):
900
- raise errors.Error(' {0} can contain only {1} '
901
- ' instances' .format(container, container.provider_type))
900
+ raise errors.Error(" {0} can contain only {1} "
901
+ " instances" .format(container, container.provider_type))
902
902
903
903
904
904
cpdef bint _any_relative_string_imports_in(object modules):
0 commit comments