Skip to content

Support for python 3.5 async/await keywords #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

MarSoft
Copy link
Contributor

@MarSoft MarSoft commented Dec 7, 2015

Highlight them and fix folding of "async def" functions

Highlight them and fix folding of "async def" functions
@MarSoft
Copy link
Contributor Author

MarSoft commented Dec 7, 2015

This should fix issue #616

@tony
Copy link

tony commented Dec 30, 2015

#627 came first, what's the difference in both of your approaches?

@tony
Copy link

tony commented Dec 30, 2015

#627 doesn't having the folding regex portion, so this PR makes sense.

@@ -75,6 +75,7 @@ endif
syn keyword pythonStatement yield
syn keyword pythonLambdaExpr lambda
syn keyword pythonStatement with as
syn keyword pythonStatement async await
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice https://github.com/klen/python-mode/pull/627/files is a bit more elaborate than this. What's the difference in how it'd work?

tony added a commit to tony/python-mode that referenced this pull request Dec 30, 2015
@MarSoft
Copy link
Contributor Author

MarSoft commented Dec 30, 2015

#627 implements async keyword better; I think their approach is preferred.

@tony
Copy link

tony commented Dec 30, 2015

Amend yours without the async part. Then we can accept both PR’s.

I’m working off a branch with that configuration ATM. I can confirm it works for me.

@MarSoft
Copy link
Contributor Author

MarSoft commented Dec 30, 2015

But on the other hand, async and await will become reserved keywords in Python 3.7 (and deprecated in 3.6), so it may be helpful to highlight them accordingly regardless of position - in order to avoid accidentally using them as variable names etc.
https://docs.python.org/3.6/whatsnew/3.6.html#deprecated

@andriykohut
Copy link
Contributor

Good point, I added async to statements in my PR

@tony
Copy link

tony commented Dec 30, 2015

Good point.

I’m fine with either approach.

Wouldn’t that break highlighting for lower python versions though?

@andriykohut
Copy link
Contributor

It will mean that async will be highlighted as a keyword everywhere (not only with def/for/with). Not sure it's a big deal, await should be a keyword anyway to make this work.

@tony
Copy link

tony commented Dec 30, 2015

+1 for thinking ahead. Though I wouldn’t want to break highlighting for older python versions. Most projects are still using Python 2.x at this time. It’s not always the developer’s choice what python version and conventions they use.

While it’s probably best practice for developers on lower versions to abstain from using future reserved keywords, highlighting should reflect the python version being used accurately.

Have you considered any ways to support all 3 cases, 3.4 and below, 3.5 and 3.6+

@tony
Copy link

tony commented Dec 30, 2015

It's not a big deal to me personally. To people on legacy projects, it's hard to tell. It can be highly annoying to have local variables highlighted as keywords.

@andriykohut
Copy link
Contributor

Yep, totally agree:

How about adding possibility to disable highlighting for async/await:
https://github.com/klen/python-mode/pull/627/files#diff-93673e8a4fc12998d3ba57063e333855R107

Like this let g:pymode_syntax_highlight_async_await = 0

@klen
Copy link
Collaborator

klen commented Jan 11, 2016

Fixed by #627 Thank you @MarSoft !

@klen klen closed this Jan 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants