Packages: Python 3 Type Annotations

Created on 1 Mar 2016  路  10Comments  路  Source: sublimehq/Packages

Type annotations from Python3 are troubling Sublime (Stable Channel, Build 3103)'s Python docstring syntax-highlighting. No plugins are present in my default Windows 7 64bit Sublime installation.
capture

bug

All 10 comments

Can you paste the actual code here?

The Python Improved language syntax already fully supports type annotations, if you'd like to try it out.

Relevant: https://www.python.org/dev/peps/pep-3107/

I would suggest properly separating the python lexer into expressions and statements, which makes arbitrary function annotations (and default values too?) easier to handle, probably. It's what I wanted to do for quite a while anyway.

@FichteFoll on this repo, or Python Improved? I've started a sublime-syntax branch, and I'm open to a rewrite/reorg if you're interested.

In general.

I would rather patch/replace the shipped Python instead of iterating on Python Improved.

I just left a comment on https://github.com/sublimehq/Packages/issues/51#issuecomment-191195465.

In short, I greatly appreciate all of the work that went into Python Improved, but I'm not currently comfortable merging in a big change like that. I'd rather see small, focused issues/PRs and move forward that way. It is easier for me to review and/or implement in small chunks. I think it will also be easier for others to help review. It also reduces the chances of changes drastically affecting the syntax highlighting of Python, such as what happened with JavaScript in build 3103.

@wbond I agree - I definitely wouldn't want to do a wholesale replacement of the original for PI, as PI still has some issues to be worked out and features to be added. I'll keep working on PI in my spare time to add new features like str.format() highlighting and f-strings for Python 3.6. However, I'll also start issuing some small PRs for this repo, perhaps for necessary Python 3 stuff like function annotations and coroutines, then working backwards to clean up magic names and functions, properly classifying builtins and whatnot, adding full Unicode support, and whatever else comes along.

For speed testing, do you have any favorite files in the stdlib that are really large? I have some smaller files for use with scope testing QA, but it'd be nice to have a good large file for benchmarking. Preferably something that's not 80% docstrings :grinning:

@wbond how "nailed-down" is the new Python.sublime-syntax? Meaning, can I start working on it to add support for type annotations and not have to worry about major parts changing under me? Also, do you and Jon have an approximate release date for 3112? I ask because if you're planning on releasing the reworked Python syntax with 3112, I'd like to work on my color scheme to support it.

@MattDMo I've been working on Python heavily today and will likely have annotations done by the end of the day, plus most likely async/await.

In general the scopes are not being changed much, I'm trying to bring all of the syntaxes in line with the commonly-used scopes out there.

There will likely be some meta scope changes, but generally those shouldn't affect color schemes much. They are more useful for detecting symbols and controlling the indexer.

I do not know when 3112 will come out. Jon deals with releases and scheduling them.

This has been added in 830956cbfc6e925b82131b8431586c7042673a48. Please open a new issue if you find any bugs with it.

Was this page helpful?
0 / 5 - 0 ratings