Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

F-strings!!! #22

Closed
wants to merge 3 commits into from
Closed

F-strings!!! #22

wants to merge 3 commits into from

Conversation

refi64
Copy link

@refi64 refi64 commented Oct 20, 2016

Well, this was a bit more complicated than I thought...

@refi64
Copy link
Author

refi64 commented Oct 28, 2016

@ddfisher Bu-uuuuump?

@ddfisher
Copy link
Collaborator

Sorry for being slow to review this! I was hoping to get to it this week but had some other things take precedence. It's at the top of my list for next week!

@ddfisher
Copy link
Collaborator

ddfisher commented Nov 2, 2016

This PR has made me realize that the typed_ast update process needs to be nailed down a bit better -- I should have something written up about that shortly, but this PR is blocking on that happening, sorry!

@JelleZijlstra
Copy link
Member

Any updates here? It would be great to have f-strings supported in mypy before CPython 3.6 final comes out. I can help if necessary.

@mbdevpl
Copy link

mbdevpl commented Dec 27, 2016

Python 3.6 is here, and...

Traceback (most recent call last):
  File "/home/user/Projects/python/typed-astunparse/test/test_unparse.py", line 80, in test_files
    tree = typed_ast.ast35.parse(source=original_code, filename=path)
  File "/home/user/.local/lib/python3.6/site-packages/typed_ast/ast35.py", line 46, in parse
    return _ast35._parse(source, filename, mode)
  File "/home/user/.local/lib/python3.6/functools.py", line 286
    args.extend(f"{k}={v!r}" for (k, v) in self.keywords.items())
                           ^
SyntaxError: invalid syntax

What can I do to help?

@yan12125
Copy link

@mbdevpl I guess you mix 3.5 and 3.6?

@mbdevpl
Copy link

mbdevpl commented Dec 28, 2016

@yan12125 this PR contains changes to ast35 which actually make it a kind of "ast36" (or some intermediate between 3.5 and 3.6), so after merging this PR the error should disappear... As mentioned in #18 , ast35 might eventually be renamed to ast3.

So, am I really mixing 3.5 and 3.6 here?

@yan12125
Copy link

functools.py is part of standard Python library and is unrelated to typed_ast. A common reason for syntax error in this file is that you're running the Python 3.5 interpreter and using Python 3.6's library.

How did you run your program?

@mbdevpl
Copy link

mbdevpl commented Jan 11, 2017

So, first of all, I compiled Python 3.6.0 from source, and installed using make altinstall to ~/.local - just like I did with Python 3.5.2 some time ago. And then I ran python3.6 setup.py test. With python3.5 my tests pass just like they used to. The test which fails there is about roundtrip parsing and unparsing typed Python ASTs (using typed_ast and typed_astunparse modules).

I think the problem at hand is not that I mix 3.5 and 3.6, but that this PR is still not merged, hence this error. And thus my question, what can I do to help in bringing f-strings to typed_ast?

@gvanrossum
Copy link
Member

Patience please. See python/mypy#2622

@mbdevpl
Copy link

mbdevpl commented Jan 12, 2017

@gvanrossum Thank you for that reference. Ok, I'll just wait then.

@ddfisher
Copy link
Collaborator

Fstrings are now supported. Sorry for the long wait! In the process of reviewing this PR, I realized that porting new Python features onto typed_ast was not the best way to go about things, because pull requests like this are difficult to review, and because typed_ast was turning into a mishmash of Python 3.5 and Python 3.6 syntax (both in parsing and in the produced AST). In lieu of merging this PR, I've instead rebuilt typed_ast on top of the Python 3.6 ast module. I've also formalized the update process for the future, so there shouldn't be such long waits again (see here).

I appreciate your working in putting up this PR, @kirbyfan64 -- sorry it's not getting landed.

@ddfisher ddfisher closed this Feb 13, 2017
@santagada
Copy link

no worries, thanks for your work, I can now run mypy again on all my code \o/

@refi64
Copy link
Author

refi64 commented Feb 13, 2017

I'm just happy that f-strings finally work!! :D

tbbharaj pushed a commit to tbbharaj/typed_ast that referenced this pull request Dec 6, 2021
Optionally disable contentSize frame header
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants