Message402868
Sorry, I think we shouldn't be changing `ast.py` this way. To reiterate my review comment from the PR:
I think we should just let this go and instead advertise that if you put new synthetic nodes in a tree, you have to either:
- provide `lineno` and `col_offset` yourself; or
- use `fix_missing_locations()` to fill out the information for you.
The problem with the logic that I commented on twice now (on the PR) is one reason for my opinion. Another is bigger though:
Suppose user code is replacing nodes or just inserting new ones. This operation not only creates nodes without location attributes. It also in all likelihood *moves* locations of type comments and those aren't updated (for example, `_type_ignores[123]` should now really be `_type_ignores[125]` to still point at the same tokens). So user code shouldn't be naive when it comes to missing locations, and we definitely shouldn't paper over missing locations. |
|
Date |
User |
Action |
Args |
2021-09-29 13:17:09 | lukasz.langa | set | recipients:
+ lukasz.langa, brett.cannon, benjamin.peterson, Mark.Shannon, yselivanov, pablogsal, BTaskaya, xiaket |
2021-09-29 13:17:09 | lukasz.langa | set | messageid: <1632921429.6.0.989095203821.issue44896@roundup.psfhosted.org> |
2021-09-29 13:17:09 | lukasz.langa | link | issue44896 messages |
2021-09-29 13:17:09 | lukasz.langa | create | |
|