Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Mar 18, 2024
1 parent 4693bf3 commit 95520c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ show_error_codes = true
pretty = true

[[tool.mypy.overrides]]
module = ["tests"]
module = ["tests.*"]
disallow_untyped_defs = false

# https://github.com/mgedmin/check-manifest#configuration
Expand Down
18 changes: 9 additions & 9 deletions tests/test_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ def process_int(x: int) -> None:

def test_injection_with_generator():
@inject
def f(x: int):
def f(x: int) -> int:
yield x

# setting the accessor to our local viewer
with register(providers={int: lambda: 1}):
assert tuple(f()) == (1,)
assert tuple(f()) == (1,) # type: ignore


def test_injection_without_args():
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_injection_errors(in_func, on_unresolved, on_unannotated):
assert (out_func is in_func) is expect_same_func_back


def test_processors_not_passed_none(test_store: Store):
def test_processors_not_passed_none(test_store: Store) -> None:
@test_store.inject_processors
def f(x: int) -> Optional[int]:
return x if x > 5 else None
Expand All @@ -184,11 +184,11 @@ def process_int(x: int) -> None:
mock.assert_called_once_with(10)


def test_optional_provider_with_required_arg(test_store: Store):
def test_optional_provider_with_required_arg(test_store: Store) -> None:
mock = Mock()

@inject(store=test_store)
def f(x: int):
def f(x: int) -> None:
mock(x)

with test_store.register(providers={Optional[int]: lambda: None}):
Expand Down Expand Up @@ -233,7 +233,7 @@ def generator_func() -> Generator:


def test_wrapped_functions():
def func(foo: Foo):
def func(foo: Foo) -> Foo:
return foo

@functools.wraps(func)
Expand All @@ -251,12 +251,12 @@ def wrapper2(*args, **kwargs):
assert injected() == foo


def test_partial_annotations(test_store: Store):
def func(foo: "Foo", bar: "Bar"): # noqa
def test_partial_annotations(test_store: Store) -> None:
def func(foo: "Foo", bar: "Bar") -> tuple["Foo", "Bar"]: # type: ignore # noqa
return foo, bar

# other way around
def func2(bar: "Bar", foo: "Foo"): # noqa
def func2(bar: "Bar", foo: "Foo") -> tuple["Foo", "Bar"]: # type: ignore # noqa
return foo, bar

with pytest.warns(UserWarning):
Expand Down

0 comments on commit 95520c8

Please sign in to comment.