diff options
author | Damien George <damien@micropython.org> | 2020-06-16 22:49:25 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-06-16 23:18:01 +1000 |
commit | f2e267da68bf85f3f12fa77155e469352bdc6c09 (patch) | |
tree | 1387eb6b017d621fe04b75f5ab576bd3b7268d23 /tests/basics/annotate_var.py.exp | |
parent | 131b0de70a47861c266d2ac7c26ae643f679d2f7 (diff) | |
download | micropython-f2e267da68bf85f3f12fa77155e469352bdc6c09.tar.gz micropython-f2e267da68bf85f3f12fa77155e469352bdc6c09.zip |
py/compile: Implement PEP 526, syntax for variable annotations.
This addition to the grammar was introduced in Python 3.6. It allows
annotating the type of a varilable, like:
x: int = 123
s: str
The implementation in this commit is quite simple and just ignores the
annotation (the int and str bits above). The reason to implement this is
to allow Python 3.6+ code that uses this feature to compile under
MicroPython without change, and for users to use type checkers.
In the future viper could use this syntax as a way to give types to
variables, which is currently done in a bit of an ad-hoc way, eg
x = int(123). And this syntax could potentially be used in the inline
assembler to define labels in an way that's easier to read.
Diffstat (limited to 'tests/basics/annotate_var.py.exp')
0 files changed, 0 insertions, 0 deletions