[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] Re: extending ast.parse with some lib2to3.pytree features
From:       Jelle Zijlstra <jelle.zijlstra () gmail ! com>
Date:       2021-11-22 15:05:25
Message-ID: CAFp3-p_g4sz71HE9vDPQ8gxBBuBb=e2P7135pfi5B8eNS2hb2g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


El dom, 21 nov 2021 a las 14:35, Peter Ludemann (<peter.ludemann@gmail.com>=
)
escribi=C3=B3:

> Neil Girdhar wrote:
> > I wish this had gotten more attention! :)
>
> I wonder what the various projects are doing to handle the latest version
> of Python, if they need a parse tree with whitespace information. (The
> projects I know of are yapf, black, mypy, pytype, kythe -- are there
> others?)
>
mypy just uses the ast module; it doesn't care about whitespace.

For Black, we're using a patched version of lib2to3. Batuhan kindly
contributed a patch that extends our version of lib2to3 to mostly parse the
match statement (https://github.com/psf/black/pull/2586).

And I had never heard of kythe, so I am going to look that up now.


>
> ast.parse() has an option `type_comments`, so certain kinds of comments
> are handled -- I wonder how much work it would be to extend this to handl=
e
> all whitespace?
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-leave@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/747=
HHPVSNK6TCSOZHJHUEUDX2GKQROKN/
> Code of Conduct: http://python.org/psf/codeofconduct/
>

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">El dom, 21 nov 2021 a las 14:35, Peter Ludemann (&lt;<a \
href="mailto:peter.ludemann@gmail.com">peter.ludemann@gmail.com</a>&gt;) \
escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Neil Girdhar \
wrote:<br> &gt; I wish this had gotten more attention! :)<br>
<br>
I wonder what the various projects are doing to handle the latest version of Python, \
if they need a parse tree with whitespace information. (The projects I know of are \
yapf, black, mypy, pytype, kythe -- are there others?)<br></blockquote><div>mypy just \
uses the ast module; it doesn&#39;t care about \
whitespace.</div><div><br></div><div>For Black, we&#39;re using a patched version of \
lib2to3. Batuhan kindly contributed a patch that extends our version of lib2to3 to \
mostly parse the match statement (<a \
href="https://github.com/psf/black/pull/2586">https://github.com/psf/black/pull/2586</a>).</div><div><br></div><div>And \
I had never heard of kythe, so I am going to look that up now.</div><div>  \
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px \
solid rgb(204,204,204);padding-left:1ex"> <br>
ast.parse() has an option `type_comments`, so certain kinds of comments are handled \
-- I wonder how much work it would be to extend this to handle all whitespace?<br> \
_______________________________________________<br> Python-ideas mailing list -- <a \
href="mailto:python-ideas@python.org" target="_blank">python-ideas@python.org</a><br> \
To unsubscribe send an email to <a href="mailto:python-ideas-leave@python.org" \
target="_blank">python-ideas-leave@python.org</a><br> <a \
href="https://mail.python.org/mailman3/lists/python-ideas.python.org/" \
rel="noreferrer" target="_blank">https://mail.python.org/mailman3/lists/python-ideas.python.org/</a><br>
 Message archived at <a \
href="https://mail.python.org/archives/list/python-ideas@python.org/message/747HHPVSNK6TCSOZHJHUEUDX2GKQROKN/" \
rel="noreferrer" target="_blank">https://mail.python.org/archives/list/python-ideas@python.org/message/747HHPVSNK6TCSOZHJHUEUDX2GKQROKN/</a><br>
 Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" \
target="_blank">http://python.org/psf/codeofconduct/</a><br> \
</blockquote></div></div>



_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/LETCFPQEKCRPRJTXZEMZIDGWKSR7LVDK/
 Code of Conduct: http://python.org/psf/codeofconduct/



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic