diff --git a/examples/__init__.py b/examples/__init__.py index db01e64..e76e3ca 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -3,5 +3,4 @@ class Example(ABC): @abstractmethod - def run(self): - ... + def run(self): ... diff --git a/examples/annotated_usage/annotated_usage_example.py b/examples/annotated_usage/annotated_usage_example.py index 04a5d7b..38f6003 100644 --- a/examples/annotated_usage/annotated_usage_example.py +++ b/examples/annotated_usage/annotated_usage_example.py @@ -25,6 +25,7 @@ The :ref:`namespaces_example` details how namespaces work. """ + # sphinx-start from typing import Annotated from examples import Example diff --git a/examples/basic_usage/basic_usage_example.py b/examples/basic_usage/basic_usage_example.py index 792b3d7..8895e3d 100644 --- a/examples/basic_usage/basic_usage_example.py +++ b/examples/basic_usage/basic_usage_example.py @@ -20,6 +20,7 @@ The :ref:`singleton_example` shows how to make a dependency to be shared for all injections instead of having the default behavior of independent instances. """ + # sphinx-start from examples import Example from examples.basic_usage.basic_service import BasicService diff --git a/examples/cyclic_dependency/cyclic_dependency_example.py b/examples/cyclic_dependency/cyclic_dependency_example.py index 43a9fa6..7e3cacf 100644 --- a/examples/cyclic_dependency/cyclic_dependency_example.py +++ b/examples/cyclic_dependency/cyclic_dependency_example.py @@ -15,6 +15,7 @@ The :ref:`lazy_injection_example` details how lazy injection works. """ + # sphinx-start from examples import Example from injectable import Autowired, autowired, load_injection_container diff --git a/examples/dependencies_precedence/abstract_service.py b/examples/dependencies_precedence/abstract_service.py index a539f18..cda41da 100644 --- a/examples/dependencies_precedence/abstract_service.py +++ b/examples/dependencies_precedence/abstract_service.py @@ -3,5 +3,4 @@ class AbstractService(ABC): @abstractmethod - def combine(self, a, b): - ... + def combine(self, a, b): ... diff --git a/examples/dependencies_precedence/dependencies_precedence_example.py b/examples/dependencies_precedence/dependencies_precedence_example.py index 5589827..0eee80b 100644 --- a/examples/dependencies_precedence/dependencies_precedence_example.py +++ b/examples/dependencies_precedence/dependencies_precedence_example.py @@ -23,6 +23,7 @@ class we will get an instance of the ``SumService`` class since we declared it a The :ref:`qualifier_overloading_example` shows how to get all instances which resolves a dependency instead of just the primary one. """ + # sphinx-start from examples import Example from examples.dependencies_precedence.abstract_service import AbstractService diff --git a/examples/factory/factory_example.py b/examples/factory/factory_example.py index fe46aa3..f46fe3d 100644 --- a/examples/factory/factory_example.py +++ b/examples/factory/factory_example.py @@ -19,6 +19,7 @@ class through the :meth:`@injectable_factory ` de used in lambdas for simpler cases. The :ref:`injecting_existing_instance_example` shows how to use it like so. """ + # sphinx-start from examples import Example from examples.factory.external_client import ExternalClient diff --git a/examples/injectable_mocking_for_tests/injectable_mocking_example.py b/examples/injectable_mocking_for_tests/injectable_mocking_example.py index e7b6e39..5392fa6 100644 --- a/examples/injectable_mocking_for_tests/injectable_mocking_example.py +++ b/examples/injectable_mocking_for_tests/injectable_mocking_example.py @@ -12,6 +12,7 @@ :meth:`load_injection_container ` was never called we wouldn't need to use :meth:`clear_injectables `. """ + # sphinx-start from unittest.mock import Mock diff --git a/examples/injecting_existing_instance/injecting_existing_instance_example.py b/examples/injecting_existing_instance/injecting_existing_instance_example.py index d42854d..fb3c8ac 100644 --- a/examples/injecting_existing_instance/injecting_existing_instance_example.py +++ b/examples/injecting_existing_instance/injecting_existing_instance_example.py @@ -15,6 +15,7 @@ used in regular functions and not just in lambdas. The :ref:`factory_example` shows how to use it. """ + # sphinx-start from examples import Example from examples.injecting_existing_instance.app import Application diff --git a/examples/injection_container_resetting_for_tests/injection_container_resetting_example.py b/examples/injection_container_resetting_for_tests/injection_container_resetting_example.py index 54be6f5..6d443ca 100644 --- a/examples/injection_container_resetting_for_tests/injection_container_resetting_example.py +++ b/examples/injection_container_resetting_for_tests/injection_container_resetting_example.py @@ -4,6 +4,7 @@ clear all state from the injection container including all registered injectables and namespaces. """ + # sphinx-start from examples import Example from injectable import ( diff --git a/examples/lazy_injection/lazy_injection_example.py b/examples/lazy_injection/lazy_injection_example.py index fef9720..e7889f0 100644 --- a/examples/lazy_injection/lazy_injection_example.py +++ b/examples/lazy_injection/lazy_injection_example.py @@ -19,6 +19,7 @@ The :ref:`cyclic_dependency_example` details how to leverage lazy injection to deal with circular references. """ + # sphinx-start from examples import Example from examples.lazy_injection.service_a import ServiceA diff --git a/examples/namespaces/namespaces_example.py b/examples/namespaces/namespaces_example.py index 49ab916..47f23fd 100644 --- a/examples/namespaces/namespaces_example.py +++ b/examples/namespaces/namespaces_example.py @@ -30,6 +30,7 @@ The :ref:`optional_injection_example` details how declaring an injection as optional works. """ + # sphinx-start from typing import Optional diff --git a/examples/optional_injection/optional_injection_example.py b/examples/optional_injection/optional_injection_example.py index 1204102..126c5a7 100644 --- a/examples/optional_injection/optional_injection_example.py +++ b/examples/optional_injection/optional_injection_example.py @@ -27,6 +27,7 @@ The :ref:`qualifier_overloading_example` shows how to use :class:`typing.List` to get all instances which resolves a dependency instead of just the primary one. """ + # sphinx-start from typing import Optional, List diff --git a/examples/qualifier_overloading/qualifier_overloading_example.py b/examples/qualifier_overloading/qualifier_overloading_example.py index 2ad3efb..bf59d78 100644 --- a/examples/qualifier_overloading/qualifier_overloading_example.py +++ b/examples/qualifier_overloading/qualifier_overloading_example.py @@ -22,6 +22,7 @@ regards to precedence when a qualifier or class are resolved by multiple injectables and you're injecting a single instance and not all matching injectables. """ + # sphinx-start from typing import List diff --git a/examples/qualifier_overloading/sender_service.py b/examples/qualifier_overloading/sender_service.py index 66efa4c..a365fdb 100644 --- a/examples/qualifier_overloading/sender_service.py +++ b/examples/qualifier_overloading/sender_service.py @@ -3,5 +3,4 @@ class SenderService(ABC): @abstractmethod - def send(self, message, recipient): - ... + def send(self, message, recipient): ... diff --git a/examples/service_locator/service_locator_example.py b/examples/service_locator/service_locator_example.py index 77c85be..d4ae928 100644 --- a/examples/service_locator/service_locator_example.py +++ b/examples/service_locator/service_locator_example.py @@ -30,6 +30,7 @@ The :ref:`qualifier_overloading_example` details how overloading an injectable works by using class inheritance. """ + # sphinx-start from examples import Example from examples.service_locator.sample_service import SampleService diff --git a/examples/singletons/singleton_example.py b/examples/singletons/singleton_example.py index fe54586..adc0a26 100644 --- a/examples/singletons/singleton_example.py +++ b/examples/singletons/singleton_example.py @@ -11,6 +11,7 @@ between injections a change to its state is then reflected to every other place injected with it. """ + # sphinx-start from examples import Example from examples.singletons.singleton_client import SingletonClient diff --git a/examples/tldr/tldr_example.py b/examples/tldr/tldr_example.py index a332092..8c76d65 100644 --- a/examples/tldr/tldr_example.py +++ b/examples/tldr/tldr_example.py @@ -6,6 +6,7 @@ For better understanding of this framework you can look at the other examples in the :ref:`usage_examples` section. The :ref:`basic_usage_example` is a good start! """ + # sphinx-start from examples import Example from injectable import injectable, autowired, Autowired, load_injection_container diff --git a/injectable/__init__.py b/injectable/__init__.py index 167c4c6..27b77ba 100644 --- a/injectable/__init__.py +++ b/injectable/__init__.py @@ -6,6 +6,7 @@ The :ref:`usage_examples` section presents a collection of examples on how to use this API. """ + from injectable.autowiring.autowired_type import Autowired from injectable.autowiring.autowired_decorator import autowired from injectable.container.injection_container import InjectionContainer diff --git a/injectable/errors/__init__.py b/injectable/errors/__init__.py index e8bc6fb..f17a5dc 100644 --- a/injectable/errors/__init__.py +++ b/injectable/errors/__init__.py @@ -1,6 +1,7 @@ """ Custom exceptions raised by injectable. """ + from injectable.errors.autowiring_error import AutowiringError from injectable.errors.injection_error import InjectionError diff --git a/injectable/testing/__init__.py b/injectable/testing/__init__.py index 46a5f3b..86f8da6 100644 --- a/injectable/testing/__init__.py +++ b/injectable/testing/__init__.py @@ -16,6 +16,7 @@ The :ref:`injection_container_resetting_example` in the :ref:`usage_examples` section shows how to use these utilities for clearing the injection container state. """ + from injectable.testing.clear_injectables_util import clear_injectables from injectable.testing.register_injectables_util import register_injectables from injectable.testing.reset_injection_container_util import reset_injection_container diff --git a/requirements.dev.txt b/requirements.dev.txt index c0229da..de0ca8f 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -4,7 +4,7 @@ pytest~=6.2 pytest-mock~=3.6 pytest-cov~=2.12 coveralls~=3.2 -black~=23.12 +black~=24.4.2 flake8~=7.1.0 sphinx~=4.1 sphinx_py3doc_enhanced_theme~=2.4 diff --git a/tests/fixes/issue_15/issue_15_fix_test.py b/tests/fixes/issue_15/issue_15_fix_test.py index e1420ee..0e0f2ec 100644 --- a/tests/fixes/issue_15/issue_15_fix_test.py +++ b/tests/fixes/issue_15/issue_15_fix_test.py @@ -9,6 +9,7 @@ This issue was fixed in injectable 3.4.1. """ + from injectable import injectable, autowired, Autowired, load_injection_container diff --git a/tests/fixes/issue_16/issue_16_fix_test.py b/tests/fixes/issue_16/issue_16_fix_test.py index 5e6e267..f7c9a8e 100644 --- a/tests/fixes/issue_16/issue_16_fix_test.py +++ b/tests/fixes/issue_16/issue_16_fix_test.py @@ -9,6 +9,7 @@ This issue was fixed in injectable 3.4.2. """ + from typing import Optional from injectable import autowired, Autowired diff --git a/tests/fixes/issue_30/issue_30_fix_test.py b/tests/fixes/issue_30/issue_30_fix_test.py index 1cbb855..aa83027 100644 --- a/tests/fixes/issue_30/issue_30_fix_test.py +++ b/tests/fixes/issue_30/issue_30_fix_test.py @@ -8,13 +8,13 @@ This issue was fixed in injectable 3.4.3. """ + from injectable import autowired, Autowired, load_injection_container from injectable.testing import reset_injection_container @autowired -def f(foo: Autowired("foo")): - ... +def f(foo: Autowired("foo")): ... def test_issue_30_fix(): diff --git a/tests/fixes/issue_30/test_module/utils/some_util.py b/tests/fixes/issue_30/test_module/utils/some_util.py index bf6963c..7429d15 100644 --- a/tests/fixes/issue_30/test_module/utils/some_util.py +++ b/tests/fixes/issue_30/test_module/utils/some_util.py @@ -1,2 +1 @@ -def some_util(): - ... +def some_util(): ... diff --git a/tests/fixes/issue_41/issue_41_fix_test.py b/tests/fixes/issue_41/issue_41_fix_test.py index 5ff1d74..927be3b 100644 --- a/tests/fixes/issue_41/issue_41_fix_test.py +++ b/tests/fixes/issue_41/issue_41_fix_test.py @@ -13,6 +13,7 @@ fail to load the injection container. The workaround for now would be to use absolute imports or to declare the injectables in a separated file. """ + from injectable import autowired, Autowired, load_injection_container from injectable.testing import reset_injection_container diff --git a/tests/fixes/issue_41/test_module/utils/some_util.py b/tests/fixes/issue_41/test_module/utils/some_util.py index bf6963c..7429d15 100644 --- a/tests/fixes/issue_41/test_module/utils/some_util.py +++ b/tests/fixes/issue_41/test_module/utils/some_util.py @@ -1,2 +1 @@ -def some_util(): - ... +def some_util(): ... diff --git a/tests/fixes/issue_8/issue_8_fix_test.py b/tests/fixes/issue_8/issue_8_fix_test.py index 47687e6..cbf4be8 100644 --- a/tests/fixes/issue_8/issue_8_fix_test.py +++ b/tests/fixes/issue_8/issue_8_fix_test.py @@ -10,6 +10,7 @@ This issue was fixed in injectable 3.1.4. """ + from typing import List from injectable import injectable, autowired, Autowired, load_injection_container diff --git a/tests/fixes/issue_80/issue_80_fix_test.py b/tests/fixes/issue_80/issue_80_fix_test.py index 1b48bc8..d945f23 100644 --- a/tests/fixes/issue_80/issue_80_fix_test.py +++ b/tests/fixes/issue_80/issue_80_fix_test.py @@ -9,6 +9,7 @@ This issue was fixed in injectable 3.4.5. """ + from injectable import injectable, autowired, Autowired, load_injection_container diff --git a/tests/fixes/issue_81/issue_81_fix_test.py b/tests/fixes/issue_81/issue_81_fix_test.py index 79275d2..b0e8512 100644 --- a/tests/fixes/issue_81/issue_81_fix_test.py +++ b/tests/fixes/issue_81/issue_81_fix_test.py @@ -11,6 +11,7 @@ This issue was fixed in injectable 3.4.6. """ + from injectable import Injectable, inject from injectable.testing import register_injectables, reset_injection_container diff --git a/tests/unit/autowiring/autowired_decorator_unit_test.py b/tests/unit/autowiring/autowired_decorator_unit_test.py index b65bd89..1ea4cb6 100644 --- a/tests/unit/autowiring/autowired_decorator_unit_test.py +++ b/tests/unit/autowiring/autowired_decorator_unit_test.py @@ -11,8 +11,7 @@ class TestAutowiredDecorator: def test__autowired__without_arguments_raises(self): # given - def f(): - ... + def f(): ... # then with pytest.raises(AutowiringError): @@ -20,8 +19,7 @@ def f(): def test__autowired__without_autowired_arguments_raises(self): # given - def f(a, b): - ... + def f(a, b): ... # then with pytest.raises(AutowiringError): @@ -29,8 +27,7 @@ def f(a, b): def test__autowired__with_autowired_arg_given_default_value_raises(self): # given - def f(a: Autowired("A") = None): - ... + def f(a: Autowired("A") = None): ... # then with pytest.raises(AutowiringError): @@ -40,8 +37,7 @@ def test__autowired__with_non_autowired_positional_arg_after_autowired_arg_raise self, ): # given - def f(a: Autowired("A"), b): - ... + def f(a: Autowired("A"), b): ... # then with pytest.raises(AutowiringError): @@ -49,8 +45,7 @@ def f(a: Autowired("A"), b): def test__autowired__with_non_autowired_var_arg_after_autowired_arg_raises(self): # given - def f(a: Autowired("A"), *b): - ... + def f(a: Autowired("A"), *b): ... # then with pytest.raises(AutowiringError): @@ -58,8 +53,7 @@ def f(a: Autowired("A"), *b): def test__autowired__with_autowired_variadic_positional_arg_raises(self): # given - def f(*a: Autowired("A")): - ... + def f(*a: Autowired("A")): ... # then with pytest.raises(AutowiringError): @@ -67,8 +61,7 @@ def f(*a: Autowired("A")): def test__autowired__with_autowired_variadic_keyword_arg_raises(self): # given - def f(**a: Autowired("A")): - ... + def f(**a: Autowired("A")): ... # then with pytest.raises(AutowiringError): @@ -76,8 +69,7 @@ def f(**a: Autowired("A")): def test__autowired__with_autowired_positional_arg_does_not_raise(self): # given - def f(a: Autowired("A")): - ... + def f(a: Autowired("A")): ... # then autowired(f) @@ -86,8 +78,7 @@ def test__autowired__with_autowired_positional_arg_following_others_does_not_rai self, ): # given - def f(a, b: Autowired("B")): - ... + def f(a, b: Autowired("B")): ... # then autowired(f) @@ -96,8 +87,7 @@ def test__autowired__with_kwonly_arg_after_autowired_positional_arg_does_not_rai self, ): # given - def f(a: Autowired("A"), *, k): - ... + def f(a: Autowired("A"), *, k): ... # then autowired(f) @@ -106,8 +96,7 @@ def test__autowired__with_var_kw_arg_after_autowired_positional_arg_does_not_rai self, ): # given - def f(a: Autowired("A"), **k): - ... + def f(a: Autowired("A"), **k): ... # then autowired(f) diff --git a/tests/unit/container/namespace_unit_test.py b/tests/unit/container/namespace_unit_test.py index 5b9f3c9..b2ec445 100644 --- a/tests/unit/container/namespace_unit_test.py +++ b/tests/unit/container/namespace_unit_test.py @@ -59,8 +59,7 @@ def test__register_injectable__propagation_to_base_classes(self): base_class = TestNamespace base_class_lookup_key = base_class.__qualname__ - class Child(base_class): - ... + class Child(base_class): ... child_class = Child child_class_lookup_key = child_class.__qualname__ @@ -79,8 +78,7 @@ def test__register_injectable__with_propagation_disabled(self): base_class = TestNamespace base_class_lookup_key = base_class.__qualname__ - class Child(base_class): - ... + class Child(base_class): ... child_class = Child child_class_lookup_key = child_class.__qualname__