You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now neither mypy's parser nor the fast parser can even parse them, let alone type-check them!
Since this is probably kind of complicated, I'd think it'd be easier to basically treat them like normal strings first and then move on to full type-checking.
@gvanrossum Haha, this is a bit more complicated than I thought. :O
So, typed_ast hasn't been updated for Python 3.6, probably since it hasn't actually been released yet. So it doesn't parse f-strings. There are two ways to fix this:
Update typed_ast for the Python 3.6 beta, then update it again when it's officially released in December.
Wait until the 3.6 release, and then update typed_ast.
Until 3.6 is released, change typed_ast to treat f-strings like normal strings, with absolutely nothing special about them. When 3.6 is released, update typed_ast.
@kirbyfan64 Note that you could not just "copy" what is in Python 3.6b to typed_ast, there are many important bookkeeping (like manually updating entry points that are not updated correctly by pgen etc). When implementing PEP 526, I did not include parts from ast.c only necessary for Python runtime, and also modified ASDL not to match Python's one, but rather to match mypy's one.
If you will need some help while implementing f-strings in typed_ast, then I will be glad to help.
Python 3.6 has been released but mypy doesn't seem to support f-strings (even with mypy-lang-0.4.7.dev0 using the latest git commit as of now).
What is the roadmap concerning the support f-strings? Thanks!
We're waiting for python/typed_ast#22 to be reviewed and merged (presumably once @ddfisher is back from the holiday break), and pushed to PyPI as a new release. Then we need changes to mypy to use that. But you (== anyone reading this) can help by working on the mypy changes now.
Thanks @gvanrossum! Could you give some indications on the changes required on mypy after the PR on typed_ast has been merged? (not to type check f-strings but just not to break on a code where f-strings are used)
Activity
gvanrossum commentedon Oct 17, 2016
That sounds like a reasonable plan. Do you feel comfortable with implementing it?
refi64 commentedon Oct 17, 2016
👍
refi64 commentedon Oct 17, 2016
@gvanrossum Haha, this is a bit more complicated than I thought. :O
So,
typed_asthasn't been updated for Python 3.6, probably since it hasn't actually been released yet. So it doesn't parse f-strings. There are two ways to fix this:typed_astfor the Python 3.6 beta, then update it again when it's officially released in December.typed_ast.typed_astto treat f-strings like normal strings, with absolutely nothing special about them. When 3.6 is released, updatetyped_ast.Which would you prefer?
gvanrossum commentedon Oct 17, 2016
refi64 commentedon Oct 17, 2016
@gvanrossum So, just to be clear, you mean option 1, right?
gvanrossum commentedon Oct 17, 2016
ilevkivskyi commentedon Oct 17, 2016
@kirbyfan64 Note that you could not just "copy" what is in Python 3.6b to
typed_ast, there are many important bookkeeping (like manually updating entry points that are not updated correctly bypgenetc). When implementing PEP 526, I did not include parts fromast.conly necessary for Python runtime, and also modified ASDL not to match Python's one, but rather to match mypy's one.If you will need some help while implementing f-strings in
typed_ast, then I will be glad to help.achauve commentedon Dec 29, 2016
Python 3.6 has been released but mypy doesn't seem to support f-strings (even with mypy-lang-0.4.7.dev0 using the latest git commit as of now).
What is the roadmap concerning the support f-strings? Thanks!
gvanrossum commentedon Dec 29, 2016
We're waiting for python/typed_ast#22 to be reviewed and merged (presumably once @ddfisher is back from the holiday break), and pushed to PyPI as a new release. Then we need changes to mypy to use that. But you (== anyone reading this) can help by working on the mypy changes now.
achauve commentedon Dec 30, 2016
Thanks @gvanrossum! Could you give some indications on the changes required on mypy after the PR on typed_ast has been merged? (not to type check f-strings but just not to break on a code where f-strings are used)
yan12125 commentedon Dec 30, 2016
After python/typed_ast#22 merged, visit_JOINEDSTR should be implemented in mypy/fastparse.py so that it can handle f-strings.
gvanrossum commentedon Feb 16, 2017
Adding some search keywords: string formatting, literal string interpolation, PEP 498.
Handle python 3.6 f-strings without error (#2622)
refi64 commentedon Mar 14, 2017
Already merged!