File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -149,16 +149,12 @@ def get_type_hints(obj: Any) -> dict[str, Any]:
149149 return get_type_hints_og (obj )
150150
151151
152- def _unionize (args : list [GenericType ]) -> type :
152+ def _unionize (args : list [GenericType ]) -> GenericType :
153153 if not args :
154154 return Any # pyright: ignore [reportReturnType]
155155 if len (args ) == 1 :
156156 return args [0 ]
157- # We are bisecting the args list here to avoid hitting the recursion limit
158- # In Python versions >= 3.11, we can simply do `return Union[*args]`
159- midpoint = len (args ) // 2
160- first_half , second_half = args [:midpoint ], args [midpoint :]
161- return Union [unionize (* first_half ), unionize (* second_half )] # pyright: ignore [reportReturnType] # noqa: UP007
157+ return Union [tuple (args )] # noqa: UP007
162158
163159
164160def unionize (* args : GenericType ) -> type :
Original file line number Diff line number Diff line change @@ -1782,6 +1782,10 @@ def figure_out_type(value: Any) -> types.GenericType:
17821782 if isinstance (value , set ):
17831783 return set [unionize (* (figure_out_type (v ) for v in value ))]
17841784 if isinstance (value , tuple ):
1785+ if not value :
1786+ return tuple [NoReturn , ...]
1787+ if len (value ) <= 5 :
1788+ return tuple [tuple (figure_out_type (v ) for v in value )]
17851789 return tuple [unionize (* (figure_out_type (v ) for v in value )), ...]
17861790 if isinstance (value , Mapping ):
17871791 if not value :
You can’t perform that action at this time.
0 commit comments