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
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Support syntax highlighting for function annotations (PEP 3107) #68
Currently the following function has it's syntax highlighting broken by having an '->' to hint at the return type of a function (this is valid syntax for Python 3.0 and above, see here).
An example:
Reacted by Jacob Hauberg Hansen, Kevin Rose, Corey Farwell, Tim, Ben Burrill, Ryan Balfanz, KINOSHITA Minoru, Guillaume DM, IwanLD, Kim Christie and 37 more
Thanks for the mention. Yes, PythonImproved fully supports multiline function annotations with or without embedded comments. I had plans at some point to port it to Atom, and even translated a version into CSON, but I haven't even had a chance to test it, let alone validate it and release it as an Atom package. Also, honestly, I've been playing around with new versions of Atom every once in a while, but I much prefer Sublime for a number of reasons (if you care, go ahead and ask me - I'm quite opinionated 😄 ), and no one has requested an Atom version yet.
If you do check out Sublime, make sure you get version 3, even though it still says "Beta" and version 2 is on the home page. There are lots of improvements in 3 over 2, and I've been using 3 pretty much exclusively for over two years now, with almost no issues at all (and those that I did have were quite a long time ago, and have since been fixed). It has the same "try before you buy" model that 2 has, in that you can use it for free indefinitely, and it'll just occasionally give you a nag screen and say UNREGISTERED in the title bar. However, if you like it, I would strongly urge you to buy a license, because you're not only supporting the developer (which is always a good thing), but you get access to the development builds where the real cutting-edge features are previewed and tweaked before making it into the public "beta" version. There's been a lot of development that's happened since the end of January, and some really cool features have been added.
Anyways, enough marketing. Try it out, install Package Control (the de facto package manager, Sublime doesn't ship with one), get Python Improved, maybe check out my Neon Color Scheme for a prettier Sublime experience, then get coding (and annotating)!
MagicPython works well for me with function annotations.. It also has the same license (MIT). I think it would be easy to just copy the syntax rules and attribute them.
If someone wants to try to achieve that (or move Python highlighting completely over to MagicPython), please feel free to. I'd be willing to give advice along the way. See also #109.
I'm one of the MagicPython authors -- would be glad to assist you guys with any kind of integration with Atom.
Reacted by kyle-eshares, Andreas Weiden, Ryan Balfanz, festinuz, Michael K., Alex Jurkiewicz, Brenden, Guillaume DM, Alexey Strokach, Jakub Molinski and 17 more
Should we be using the MagicPython package? Just confused by @1st1's comment about integrating with Atom when there appears to already be a package.
I've installed it, and it appears to work.. but is this heading for atom/language-python, and I should keep an eye on the changelog? Or use both simultaneously? (Which presently doesn't seem to be causing problems)
The Atom team is interested in switching language-python to use MagicPython. They haven't decided the best way to do that yet though. Will see if anything has changed since I last asked (but you'll probably want to subscribe to #109 for future updates).
edit: They've been busy with other stuff, but haven't forgotten about it.
Reacted by NAKATA Keisuke, Brenden, Alexey Strokach, Jakub Molinski, David Gidwani, Robert Kuykendall, AC, John Jones and Alejandro Avilés
I have added support for PEP-3107 in #228, which should ship in Atom 1.25 assuming that we do not find any regressions.
I just realized that using expressions as typehints like max(2, 9) doesn't quite work yet but I'll try to wrap up support for it soon.
Reacted by Luke Wright, Ryan Berckmans, Gregory Becker, Fernando Bernardelli, Fernando Zanutto, Henrik Böving, Jan Freyberg, Sergio García Prado, Ansel Halliburton, Khanagha A. and 2 more
Activity
auscompgeek commentedon Jul 3, 2015
This also affects annotations on function parameters (supposed to be orange and italics here):
auscompgeek commentedon Jul 3, 2015
The PythonImproved package by @MattDMo for Sublime Text has support for function annotations, perhaps that might be useful.
MattDMo commentedon Jul 4, 2015
Thanks for the mention. Yes, PythonImproved fully supports multiline function annotations with or without embedded comments. I had plans at some point to port it to Atom, and even translated a version into CSON, but I haven't even had a chance to test it, let alone validate it and release it as an Atom package. Also, honestly, I've been playing around with new versions of Atom every once in a while, but I much prefer Sublime for a number of reasons (if you care, go ahead and ask me - I'm quite opinionated 😄 ), and no one has requested an Atom version yet.
If you do check out Sublime, make sure you get version 3, even though it still says "Beta" and version 2 is on the home page. There are lots of improvements in 3 over 2, and I've been using 3 pretty much exclusively for over two years now, with almost no issues at all (and those that I did have were quite a long time ago, and have since been fixed). It has the same "try before you buy" model that 2 has, in that you can use it for free indefinitely, and it'll just occasionally give you a nag screen and say
UNREGISTEREDin the title bar. However, if you like it, I would strongly urge you to buy a license, because you're not only supporting the developer (which is always a good thing), but you get access to the development builds where the real cutting-edge features are previewed and tweaked before making it into the public "beta" version. There's been a lot of development that's happened since the end of January, and some really cool features have been added.Anyways, enough marketing. Try it out, install Package Control (the de facto package manager, Sublime doesn't ship with one), get Python Improved, maybe check out my Neon Color Scheme for a prettier Sublime experience, then get coding (and annotating)!
MatthewNewland commentedon Jul 30, 2015
You can try:
https://github.com/MatthewNewland/language-python3
MrLoh commentedon Sep 13, 2015
any developments on this? Please add support!
frankiejarrett commentedon Nov 27, 2015
This is super annoying.
michael-k commentedon Nov 27, 2015
@MatthewNewland Your link is dead. :(
auscompgeek commentedon Nov 27, 2015
MagicPython exists for now, I guess.
alexchandel commentedon Mar 1, 2016
either MattDMo/PythonImproved, MatthewNewland/language-python3, or MagicStack/MagicPython should be copied and merged into this.
frewsxcv commentedon May 4, 2016
MagicPython works well for me with function annotations.. It also has the same license (MIT). I think it would be easy to just copy the syntax rules and attribute them.
winstliu commentedon May 4, 2016
If someone wants to try to achieve that (or move Python highlighting completely over to MagicPython), please feel free to. I'd be willing to give advice along the way. See also #109.
1st1 commentedon May 10, 2016
I'm one of the MagicPython authors -- would be glad to assist you guys with any kind of integration with Atom.
OJFord commentedon Jun 27, 2016
What's the status of this?
Should we be using the MagicPython package? Just confused by @1st1's comment about integrating with Atom when there appears to already be a package.
I've installed it, and it appears to work.. but is this heading for atom/language-python, and I should keep an eye on the changelog? Or use both simultaneously? (Which presently doesn't seem to be causing problems)
winstliu commentedon Jun 27, 2016
The Atom team is interested in switching
language-pythonto use MagicPython. They haven't decided the best way to do that yet though. Will see if anything has changed since I last asked (but you'll probably want to subscribe to #109 for future updates).edit: They've been busy with other stuff, but haven't forgotten about it.
OJFord commentedon Jun 27, 2016
Awesome. Thanks.
FWIW to others - I'm not having any troubles running both side by side; so I plan to continue like this until I hear that it's integrated :)
vanillajonathan commentedon Oct 2, 2016
Test case:
GabeDottl commentedon May 29, 2017
+1 - this bug is super annoying...
1st1 commentedon May 29, 2017
@GabeDottl Just install MagicPython.
dbrgn commentedon Jun 23, 2017
Was a bit stunned that Atom does not support all the Python 3 syntax. Function annotations have been in there for many years now :)
Magic Python works nicely. Would be great to have it in Atom by default. Looks like that discussion is going on in atom/atom#13877 .
winstliu commentedon Jan 25, 2018
I have added support for PEP-3107 in #228, which should ship in Atom 1.25 assuming that we do not find any regressions.
I just realized that using expressions as typehints like

max(2, 9)doesn't quite work yet but I'll try to wrap up support for it soon.