Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

> What's the issue exactly with multi-line annotations? 

The issue is that for grabbing the source, we are inspecting the tokenize 
buffer and using the information in the expr node of the annotation to know 
what we need to pick from it.

In multi-line annotations, the tokenize buffer does not contain the whole 
source, it just contains the last line.

To make it work, we would need to grab the individual tokens (because the 
tokenizer has all of them) and append them together to form the expression, but 
in this process we lose the non-significant whitespace.

---

Regarding loosing the whitespace for multi-line strings (or all string if we 
want to be consistent): the more I think about it the more I think is not that 
bad. This means that the string that the parser will place in the annotation 
field (and therefore the one that ends in __annotations__) will not have 
spaces, but the ast will be able to parse it without any problems. It will just 
look a bit crumbled, but that field is supposed to be used by tools, not 
humans, so I don't think is a huge problem.

----------

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

Reply via email to