Commit 77d6ec5
authored
Python: Add parameter
* Add type attribution tests and fix method declaration/type hint types
- Add type attribution tests to 13 existing parser test files covering
method invocations, binary ops, type hints, collection literals, imports,
field access, class instances, method declarations, async defs, for loops,
unary ops, ternaries, and lambdas
- Add `method_declaration_type()` to type_mapping.py to build JavaType.Method
for function declarations using ty-types descriptor data with annotation fallback
- Add type attribution to ParameterizedType nodes in type hint expressions
- Fix pre-existing assign_test.py bug (simple_name access, FQN startswith)
- Add typing.Text test to test_type_attribution.py
- Bump ty-types dependency to >=0.0.19.dev20260223093555
* Add parameter field_type attribution and call-site type arguments
- Add param_type_info() to PythonTypeMapping for function parameter
Identifier nodes to get JavaType.Variable field_type
- Update __convert_name() and map_arg() to flow field_type through to
J.Identifier and NamedVariable
- Use call signature returnTypeId for call-site-specific return types
(e.g. int for identity(42) instead of generic T)
- Populate _declared_formal_type_names on method invocation types from
function descriptor type parameters
- Bump ty-types to 0.0.19.dev20260223102528 for callSignature
typeArguments/returnTypeId supportfield_type attribution and call-site type arguments (#6795)1 parent ea79af4 commit 77d6ec5
6 files changed
Lines changed: 252 additions & 11 deletions
File tree
- rewrite-python/rewrite
- src/rewrite/python
- tests/python/all/tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
| 341 | + | |
| 342 | + | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
362 | | - | |
| 363 | + | |
363 | 364 | | |
364 | 365 | | |
365 | 366 | | |
| |||
3039 | 3040 | | |
3040 | 3041 | | |
3041 | 3042 | | |
3042 | | - | |
| 3043 | + | |
| 3044 | + | |
3043 | 3045 | | |
3044 | 3046 | | |
3045 | 3047 | | |
3046 | 3048 | | |
3047 | | - | |
| 3049 | + | |
3048 | 3050 | | |
3049 | 3051 | | |
3050 | 3052 | | |
| |||
3055 | 3057 | | |
3056 | 3058 | | |
3057 | 3059 | | |
3058 | | - | |
| 3060 | + | |
3059 | 3061 | | |
3060 | 3062 | | |
3061 | 3063 | | |
| |||
Lines changed: 72 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
480 | 491 | | |
481 | 492 | | |
482 | 493 | | |
| |||
533 | 544 | | |
534 | 545 | | |
535 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
536 | 551 | | |
537 | 552 | | |
538 | 553 | | |
| |||
601 | 616 | | |
602 | 617 | | |
603 | 618 | | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
604 | 629 | | |
605 | 630 | | |
606 | 631 | | |
| |||
660 | 685 | | |
661 | 686 | | |
662 | 687 | | |
663 | | - | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
664 | 695 | | |
665 | 696 | | |
666 | 697 | | |
| |||
670 | 701 | | |
671 | 702 | | |
672 | 703 | | |
| 704 | + | |
673 | 705 | | |
674 | 706 | | |
675 | 707 | | |
| |||
690 | 722 | | |
691 | 723 | | |
692 | 724 | | |
| 725 | + | |
| 726 | + | |
693 | 727 | | |
694 | 728 | | |
695 | 729 | | |
696 | 730 | | |
697 | 731 | | |
698 | 732 | | |
699 | 733 | | |
| 734 | + | |
700 | 735 | | |
701 | 736 | | |
702 | 737 | | |
| |||
729 | 764 | | |
730 | 765 | | |
731 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
732 | 775 | | |
733 | 776 | | |
734 | 777 | | |
735 | 778 | | |
736 | 779 | | |
737 | 780 | | |
738 | 781 | | |
| 782 | + | |
739 | 783 | | |
740 | 784 | | |
741 | 785 | | |
| |||
1037 | 1081 | | |
1038 | 1082 | | |
1039 | 1083 | | |
1040 | | - | |
1041 | | - | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1042 | 1088 | | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
1043 | 1098 | | |
1044 | 1099 | | |
1045 | 1100 | | |
| |||
1083 | 1138 | | |
1084 | 1139 | | |
1085 | 1140 | | |
| 1141 | + | |
| 1142 | + | |
1086 | 1143 | | |
1087 | 1144 | | |
1088 | 1145 | | |
1089 | 1146 | | |
1090 | 1147 | | |
1091 | 1148 | | |
1092 | 1149 | | |
| 1150 | + | |
1093 | 1151 | | |
1094 | 1152 | | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1095 | 1164 | | |
1096 | 1165 | | |
1097 | 1166 | | |
| |||
Lines changed: 50 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
128 | 177 | | |
129 | 178 | | |
130 | 179 | | |
| |||
Lines changed: 80 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
170 | 209 | | |
171 | 210 | | |
172 | 211 | | |
| |||
216 | 255 | | |
217 | 256 | | |
218 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments