Łukasz Langa <luk...@langa.pl> added the comment:

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.

----------
nosy: +lukasz.langa
resolution:  -> rejected
stage: patch review -> resolved

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44896>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to