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 @@ -1263,9 +1263,8 @@ def _recreate_annotated_origin(annotated_type: Any) -> Any:
12631263 if only_explicit_bindings and _inject_marker not in metadata or _noinject_marker in metadata :
12641264 del bindings [k ]
12651265 elif _is_specialization (v , Union ) or _is_new_union_type (v ):
1266- # We don't treat Optional parameters in any special way at the moment.
12671266 union_members = v .__args__
1268- new_members = tuple (set (union_members ) - { type ( None )} )
1267+ new_members = tuple (set (union_members ))
12691268 # mypy stared complaining about this line for some reason:
12701269 # error: Variable "new_members" is not valid as a type
12711270 new_union = Union [new_members ] # type: ignore
Original file line number Diff line number Diff line change @@ -1761,8 +1761,7 @@ def function(a: Inject[Inject[int]]) -> None:
17611761 assert get_bindings (function ) == {'a' : int }
17621762
17631763
1764- # This will not inject `None` even if there is a provider configured to provide
1765- # str | None elsewhere in the graph because `None` is stripped in
1764+ # This should correctly resolve str | None
17661765 @inject
17671766 def function12 (a : str | None ):
17681767 pass
@@ -1777,7 +1776,7 @@ def test_get_bindings_for_pep_604():
17771776 def function1 (a : int | None ) -> None :
17781777 pass
17791778
1780- assert get_bindings (function1 ) == {'a' : int }
1779+ assert get_bindings (function1 ) == {'a' : Union [ int , None ] }
17811780
17821781 @inject
17831782 def function1 (a : int | str ) -> None :
You can’t perform that action at this time.
0 commit comments