Skip to content

Commit

Permalink
Upgrade 'black' version
Browse files Browse the repository at this point in the history
  • Loading branch information
roo-oliv committed Jul 9, 2024
1 parent 0f704ab commit fd6f31b
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 39 deletions.
3 changes: 1 addition & 2 deletions examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

class Example(ABC):
@abstractmethod
def run(self):
...
def run(self): ...
1 change: 1 addition & 0 deletions examples/annotated_usage/annotated_usage_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
The :ref:`namespaces_example` details how namespaces work.
"""

# sphinx-start
from typing import Annotated
from examples import Example
Expand Down
1 change: 1 addition & 0 deletions examples/basic_usage/basic_usage_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/cyclic_dependency/cyclic_dependency_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions examples/dependencies_precedence/abstract_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

class AbstractService(ABC):
@abstractmethod
def combine(self, a, b):
...
def combine(self, a, b): ...
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/factory/factory_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class through the :meth:`@injectable_factory <injectable.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:meth:`load_injection_container <injectable.load_injection_container>` was never called
we wouldn't need to use :meth:`clear_injectables <injectable.testing.clear_injectables>`.
"""

# sphinx-start
from unittest.mock import Mock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions examples/lazy_injection/lazy_injection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/namespaces/namespaces_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
The :ref:`optional_injection_example` details how declaring an injection as
optional works.
"""

# sphinx-start
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions examples/optional_injection/optional_injection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions examples/qualifier_overloading/sender_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

class SenderService(ABC):
@abstractmethod
def send(self, message, recipient):
...
def send(self, message, recipient): ...
1 change: 1 addition & 0 deletions examples/service_locator/service_locator_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/singletons/singleton_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/tldr/tldr_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions injectable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions injectable/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Custom exceptions raised by injectable.
"""

from injectable.errors.autowiring_error import AutowiringError
from injectable.errors.injection_error import InjectionError

Expand Down
1 change: 1 addition & 0 deletions injectable/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/fixes/issue_15/issue_15_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
This issue was fixed in injectable 3.4.1.
"""

from injectable import injectable, autowired, Autowired, load_injection_container


Expand Down
1 change: 1 addition & 0 deletions tests/fixes/issue_16/issue_16_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
This issue was fixed in injectable 3.4.2.
"""

from typing import Optional

from injectable import autowired, Autowired
Expand Down
4 changes: 2 additions & 2 deletions tests/fixes/issue_30/issue_30_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 1 addition & 2 deletions tests/fixes/issue_30/test_module/utils/some_util.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
def some_util():
...
def some_util(): ...
1 change: 1 addition & 0 deletions tests/fixes/issue_41/issue_41_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/fixes/issue_41/test_module/utils/some_util.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
def some_util():
...
def some_util(): ...
1 change: 1 addition & 0 deletions tests/fixes/issue_8/issue_8_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/fixes/issue_80/issue_80_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
This issue was fixed in injectable 3.4.5.
"""

from injectable import injectable, autowired, Autowired, load_injection_container


Expand Down
1 change: 1 addition & 0 deletions tests/fixes/issue_81/issue_81_fix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 11 additions & 22 deletions tests/unit/autowiring/autowired_decorator_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,23 @@
class TestAutowiredDecorator:
def test__autowired__without_arguments_raises(self):
# given
def f():
...
def f(): ...

# then
with pytest.raises(AutowiringError):
autowired(f)

def test__autowired__without_autowired_arguments_raises(self):
# given
def f(a, b):
...
def f(a, b): ...

# then
with pytest.raises(AutowiringError):
autowired(f)

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):
Expand All @@ -40,44 +37,39 @@ 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):
autowired(f)

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):
autowired(f)

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):
autowired(f)

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):
autowired(f)

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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/container/namespace_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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__
Expand Down

0 comments on commit fd6f31b

Please sign in to comment.