@@ -1094,13 +1094,10 @@ def _get_annotations_for_partialmethod(partialmethod_obj, format):
10941094 partial_args = partialmethod_obj .args or ()
10951095 partial_keywords = partialmethod_obj .keywords or {}
10961096
1097- # Build new annotations dict
1097+ # Build new annotations dict in proper order
1098+ # (parameters first, then return)
10981099 new_annotations = {}
10991100
1100- # Keep return annotation if present
1101- if 'return' in func_annotations :
1102- new_annotations ['return' ] = func_annotations ['return' ]
1103-
11041101 # The first parameter (self/cls) is always kept for unbound partialmethod
11051102 first_param = func_params [0 ]
11061103 if first_param in func_annotations :
@@ -1128,6 +1125,10 @@ def _get_annotations_for_partialmethod(partialmethod_obj, format):
11281125 if param_name in func_annotations :
11291126 new_annotations [param_name ] = func_annotations [param_name ]
11301127
1128+ # Add return annotation at the end
1129+ if 'return' in func_annotations :
1130+ new_annotations ['return' ] = func_annotations ['return' ]
1131+
11311132 return new_annotations
11321133
11331134 except (ValueError , TypeError ):
@@ -1160,17 +1161,18 @@ def _get_annotations_for_partial(partial_obj, format):
11601161 return {}
11611162
11621163 # Build new annotations dict with only unbound parameters
1164+ # (parameters first, then return)
11631165 new_annotations = {}
11641166
1165- # Keep return annotation if present
1166- if 'return' in func_annotations :
1167- new_annotations ['return' ] = func_annotations ['return' ]
1168-
11691167 # Only include annotations for parameters that still exist in partial's signature
11701168 for param_name in sig .parameters :
11711169 if param_name in func_annotations :
11721170 new_annotations [param_name ] = func_annotations [param_name ]
11731171
1172+ # Add return annotation at the end
1173+ if 'return' in func_annotations :
1174+ new_annotations ['return' ] = func_annotations ['return' ]
1175+
11741176 return new_annotations
11751177
11761178
0 commit comments