File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -1253,9 +1253,8 @@ def _is_injection_annotation(annotation: Any) -> bool:
12531253 if only_explicit_bindings and _inject_marker not in metadata or _noinject_marker in metadata :
12541254 del bindings [k ]
12551255 elif _is_specialization (v , Union ) or _is_new_union_type (v ):
1256- # We don't treat Optional parameters in any special way at the moment.
12571256 union_members = v .__args__
1258- new_members = tuple (set (union_members ) - { type ( None )} )
1257+ new_members = tuple (set (union_members ))
12591258 # mypy stared complaining about this line for some reason:
12601259 # error: Variable "new_members" is not valid as a type
12611260 new_union = Union [new_members ] # type: ignore
Original file line number Diff line number Diff line change @@ -1674,8 +1674,7 @@ def function11(a: int) -> 'InvalidForwardReference':
16741674 assert get_bindings (function11 ) == {'a' : int }
16751675
16761676
1677- # This will not inject `None` even if there is a provider configured to provide
1678- # str | None elsewhere in the graph because `None` is stripped in
1677+ # This should correctly resolve str | None
16791678 @inject
16801679 def function12 (a : str | None ):
16811680 pass
@@ -1690,7 +1689,7 @@ def test_get_bindings_for_pep_604():
16901689 def function1 (a : int | None ) -> None :
16911690 pass
16921691
1693- assert get_bindings (function1 ) == {'a' : int }
1692+ assert get_bindings (function1 ) == {'a' : Union [ int , None ] }
16941693
16951694 @inject
16961695 def function1 (a : int | str ) -> None :
You can’t perform that action at this time.
0 commit comments