Commit 7bf9bc9
Python: Fix various parser issues (#6547)
* Python: Parser adaptability
* Python: Add support for PEP 695 type parameters and subscript decorators
- Implement parsing and printing for Python 3.12+ type parameters
(TypeVar, TypeVarTuple, ParamSpec) in class and function definitions
- Add support for subscript decorators (e.g., @[property][0])
- Fix f-string debug expression trailing newline issue
- Add comprehensive tests for type parameters and decorators
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Python: Commit Python parser tests
* Python: Add type parameters support to TypeAlias
Add support for PEP 695 type parameters on type alias statements
(e.g., `type Foo[T] = list[T]`).
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Fix more parser issues
* Fix statement padding
* Python: Handle UTF-8 BOM in source files
- Detect and strip BOM character (U+FEFF) before parsing
- Store BOM presence in CompilationUnit.charset_bom_marked
- Output BOM when printing if file originally had one
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Python: Fix multi-line tuple unpacking in for loops
The parser was incorrectly determining whether parentheses belong to a
tuple or its first element. The heuristic only checked column offset,
but for multi-line tuples like:
for (
window,
in_entry,
) in buf_out:
The tuple and first element have the same column offset (4) but are on
different lines. The fix now checks both line AND column to correctly
identify that the '(' belongs to the tuple itself.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Fix more parser problems
* Fix more parser problems
* Fix more parser problems
* Yet more parser fixes
* Yet more parser fixes
* Unicode fixes
* pep646
---------
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent 16f358f commit 7bf9bc9
File tree
62 files changed
+4483
-110
lines changed- rewrite-python/rewrite
- src/rewrite
- java
- python
- rpc
- test
- tests
- python
- all/tree
- py311
- py312
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
62 files changed
+4483
-110
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
Lines changed: 691 additions & 105 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
378 | 381 | | |
379 | 382 | | |
380 | 383 | | |
| |||
802 | 805 | | |
803 | 806 | | |
804 | 807 | | |
| 808 | + | |
| 809 | + | |
805 | 810 | | |
806 | 811 | | |
807 | 812 | | |
| |||
973 | 978 | | |
974 | 979 | | |
975 | 980 | | |
| 981 | + | |
| 982 | + | |
976 | 983 | | |
977 | 984 | | |
978 | 985 | | |
| |||
1343 | 1350 | | |
1344 | 1351 | | |
1345 | 1352 | | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
1346 | 1356 | | |
1347 | 1357 | | |
1348 | 1358 | | |
| |||
1531 | 1541 | | |
1532 | 1542 | | |
1533 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
1534 | 1546 | | |
1535 | 1547 | | |
1536 | 1548 | | |
| |||
1571 | 1583 | | |
1572 | 1584 | | |
1573 | 1585 | | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1574 | 1589 | | |
1575 | 1590 | | |
1576 | 1591 | | |
| |||
1640 | 1655 | | |
1641 | 1656 | | |
1642 | 1657 | | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
1643 | 1670 | | |
1644 | 1671 | | |
1645 | 1672 | | |
| |||
1794 | 1821 | | |
1795 | 1822 | | |
1796 | 1823 | | |
| 1824 | + | |
1797 | 1825 | | |
1798 | 1826 | | |
1799 | 1827 | | |
1800 | 1828 | | |
1801 | 1829 | | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
1802 | 1833 | | |
1803 | 1834 | | |
1804 | 1835 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1486 | 1486 | | |
1487 | 1487 | | |
1488 | 1488 | | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
1489 | 1496 | | |
1490 | 1497 | | |
1491 | 1498 | | |
| |||
1504 | 1511 | | |
1505 | 1512 | | |
1506 | 1513 | | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
1507 | 1518 | | |
1508 | 1519 | | |
1509 | 1520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
210 | 213 | | |
211 | | - | |
| 214 | + | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 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 | + | |
180 | 204 | | |
181 | 205 | | |
182 | 206 | | |
| |||
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments