mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
fix: code quality issues (#406)
* Refactor unnecessary `else` / `elif` when `if` block has a `return` statement * Remove unused imports * Use literal syntax to create data structure * revert "remove unused import"
This commit is contained in:
parent
5f6777db19
commit
43eb15ed65
|
@ -111,20 +111,19 @@ class ProvidersMap:
|
|||
) -> Optional[providers.Provider]:
|
||||
if isinstance(provider, providers.Delegate):
|
||||
return self._resolve_delegate(provider)
|
||||
elif isinstance(provider, (
|
||||
if isinstance(provider, (
|
||||
providers.ProvidedInstance,
|
||||
providers.AttributeGetter,
|
||||
providers.ItemGetter,
|
||||
providers.MethodCaller,
|
||||
)):
|
||||
return self._resolve_provided_instance(provider)
|
||||
elif isinstance(provider, providers.ConfigurationOption):
|
||||
if isinstance(provider, providers.ConfigurationOption):
|
||||
return self._resolve_config_option(provider)
|
||||
elif isinstance(provider, providers.TypedConfigurationOption):
|
||||
if isinstance(provider, providers.TypedConfigurationOption):
|
||||
return self._resolve_config_option(provider.option, as_=provider.provides)
|
||||
elif isinstance(provider, str):
|
||||
if isinstance(provider, str):
|
||||
return self._resolve_string_id(provider, modifier)
|
||||
else:
|
||||
return self._resolve_provider(provider)
|
||||
|
||||
def _resolve_string_id(
|
||||
|
|
|
@ -69,7 +69,7 @@ class CallableTests(unittest.TestCase):
|
|||
provider = providers.Callable(_example) \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_set_kwargs(self):
|
||||
provider = providers.Callable(_example) \
|
||||
|
|
|
@ -87,7 +87,7 @@ class CoroutineTests(AsyncTestCase):
|
|||
provider = providers.Coroutine(_example) \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_set_kwargs(self):
|
||||
provider = providers.Coroutine(_example) \
|
||||
|
|
|
@ -228,7 +228,7 @@ class FactoryTests(unittest.TestCase):
|
|||
provider = providers.Factory(Example) \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_set_kwargs(self):
|
||||
provider = providers.Factory(Example) \
|
||||
|
|
|
@ -42,7 +42,7 @@ class ListTests(unittest.TestCase):
|
|||
provider = providers.List() \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_clear_args(self):
|
||||
provider = providers.List() \
|
||||
|
|
|
@ -203,7 +203,7 @@ class ResourceTests(unittest.TestCase):
|
|||
provider = providers.Resource(init_fn) \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_clear_args(self):
|
||||
provider = providers.Resource(init_fn) \
|
||||
|
|
|
@ -190,7 +190,7 @@ class _BaseSingletonTestCase(object):
|
|||
provider = self.singleton_cls(Example) \
|
||||
.add_args(1, 2) \
|
||||
.set_args(3, 4)
|
||||
self.assertEqual(provider.args, tuple([3, 4]))
|
||||
self.assertEqual(provider.args, (3, 4))
|
||||
|
||||
def test_set_kwargs(self):
|
||||
provider = self.singleton_cls(Example) \
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
import contextlib
|
||||
from decimal import Decimal
|
||||
import importlib
|
||||
import unittest
|
||||
|
||||
from dependency_injector.wiring import (
|
||||
wire,
|
||||
Provide,
|
||||
Closing,
|
||||
register_loader_containers,
|
||||
unregister_loader_containers,
|
||||
)
|
||||
Closing)
|
||||
from dependency_injector import errors
|
||||
|
||||
# Runtime import to avoid syntax errors in samples on Python < 3.5
|
||||
|
|
Loading…
Reference in New Issue
Block a user