Skip to content
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

[Python] Add support for some new syntax in Python 3.8 #2006

Merged
merged 2 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Python/Python.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,13 @@ contexts:
- match: ','
scope: punctuation.separator.parameters.python
push: allow-unpack-operators
- match: /
scope: storage.modifier.positional-args-only.python
push:
- match: (?=[,)])
pop: true
- match: \S
scope: invalid.illegal.expected-comma.python
- match: '(?==)'
set:
- match: '='
Expand Down Expand Up @@ -1411,6 +1418,8 @@ contexts:
pop: true
- match: '![ars]'
scope: storage.modifier.conversion.python
- match: =
scope: storage.modifier.debug.python
- match: ':'
push:
- meta_scope: meta.format-spec.python constant.other.format-spec.python
Expand All @@ -1423,7 +1432,7 @@ contexts:
- match: ''
push:
- meta_content_scope: source.python.embedded
- match: (?=![^=]|:|\})
- match: (?==?(![^=]|:|\}))
pop: true
- match: \\
scope: invalid.illegal.backslash-in-fstring.python
Expand Down
9 changes: 9 additions & 0 deletions Python/syntax_test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,15 @@ def foo(arg: int = 0, (x: float, y=20) = (0.0, "default")):
# ^ punctuation.section.sequence.end.python
pass

def name(p1, p2=None, /, p_or_kw=None, *, kw): pass
# ^ storage.modifier.positional-args-only.python
# ^ punctuation.separator.parameters.python
# ^ keyword.operator.unpacking.sequence.python
def name(p1, p2, /): pass
# ^ storage.modifier.positional-args-only.python
# ^ punctuation.section.parameters.end.python


##################
# Class definitions
##################
Expand Down
27 changes: 27 additions & 0 deletions Python/syntax_test_python_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,33 @@
# ^ invalid.illegal.stray-brace
"""

# Most of these were inspired by
# https://github.com/python/cpython/commit/9a4135e939bc223f592045a38e0f927ba170da32
f'{x=:}'
# ^ storage.modifier.debug.python
f'{x=:.2f}'
# ^ storage.modifier.debug.python
f'{x=!r}'
# ^ storage.modifier.debug.python
f'{x=!a}'
# ^ storage.modifier.debug.python
f'{x=!s:*^20}'
# ^ storage.modifier.debug.python
# ^^ storage.modifier.conversion.python
# ^^^^^ meta.format-spec.python
f'{"Σ"=}'
# ^ storage.modifier.debug.python
f'{0==1}'
# ^^ -storage.modifier.debug.python
f'{0!=1}'
# ^ -storage.modifier.debug.python
f'{0<=1}'
# ^ -storage.modifier.debug.python
f'{0>=1}'
# ^ -storage.modifier.debug.python
f'{f(a="3=")}'
# ^^^^ -storage.modifier.debug.python

f" {
% ^ invalid.illegal.unclosed-string
# TODO make this test pass
Expand Down