Skip to content

Commit 3d83531

Browse files
committed
Test Union with NoInject
It's not an intended thing, but still.
1 parent 1110ac7 commit 3d83531

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

injector_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,14 @@ def function(a: Inject[Inject[int]]) -> None:
20872087
assert get_bindings(function) == {'a': int}
20882088

20892089

2090+
def test_get_bindings_excludes_union_with_a_noinject_member() -> None:
2091+
@inject
2092+
def function_with_noinject_nested_in_union(a: Union[NoInject[int], str]) -> None:
2093+
pass
2094+
2095+
assert get_bindings(function_with_noinject_nested_in_union) == {}
2096+
2097+
20902098
# Tests https://github.com/alecthomas/injector/issues/202
20912099
def test_get_bindings_for_pep_604():
20922100
@inject

0 commit comments

Comments
 (0)