Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
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

Closed

Description

@wegry

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:
screen shot 2015-06-05 at 9 42 08 pm

Activity

  1. auscompgeek commented on Jul 3, 2015

    @auscompgeek

    This also affects annotations on function parameters (supposed to be orange and italics here):

    screenshot from 2015-07-03 15-52-02

  2. auscompgeek commented on Jul 3, 2015

    @auscompgeek

    The PythonImproved package by @MattDMo for Sublime Text has support for function annotations, perhaps that might be useful.

  3. MattDMo commented on Jul 4, 2015

    @MattDMo

    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)!

  4. MatthewNewland commented on Jul 30, 2015

    @MatthewNewland
  5. MrLoh commented on Sep 13, 2015

    @MrLoh

    any developments on this? Please add support!

  6. frankiejarrett commented on Nov 27, 2015

    @frankiejarrett

    This is super annoying.

  7. michael-k commented on Nov 27, 2015

    @michael-k

    @MatthewNewland Your link is dead. :(

  8. auscompgeek commented on Nov 27, 2015

    @auscompgeek

    MagicPython exists for now, I guess.

  9. alexchandel commented on Mar 1, 2016

    @alexchandel

    either MattDMo/PythonImproved, MatthewNewland/language-python3, or MagicStack/MagicPython should be copied and merged into this.

  10. frewsxcv commented on May 4, 2016

    @frewsxcv

    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.

  11. winstliu commented on May 4, 2016

    @winstliu
    Contributor

    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.

  12. 1st1 commented on May 10, 2016

    @1st1

    I'm one of the MagicPython authors -- would be glad to assist you guys with any kind of integration with Atom.

  13. OJFord commented on Jun 27, 2016

    @OJFord

    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)

  14. winstliu commented on Jun 27, 2016

    @winstliu
    Contributor

    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.

  15. OJFord commented on Jun 27, 2016

    @OJFord

    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 :)

  16. vanillajonathan commented on Oct 2, 2016

    @vanillajonathan

    Test case:

    def syntax_highlighting_works():
        """Syntax highlighting works."""
        print('Syntax highlighting works.')
    
    
    def syntax_highlighting_bugs_out() -> None:
        """Syntax highlighting bugs out."""
        print('Syntax highlighting bugs out')
  17. GabeDottl commented on May 29, 2017

    @GabeDottl

    +1 - this bug is super annoying...

  18. 1st1 commented on May 29, 2017

    @1st1

    @GabeDottl Just install MagicPython.

  19. dbrgn commented on Jun 23, 2017

    @dbrgn

    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 .

  20. self-assigned this
    on Jan 22, 2018
  21. winstliu commented on Jan 25, 2018

    @winstliu
    Contributor

    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.
    python-annotations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions