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] Fix function-calls in inherited class definitions #4178

Merged
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
8 changes: 6 additions & 2 deletions Python/Python.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,13 @@ contexts:
pop: 1
- match: ','
scope: punctuation.separator.inheritance.python
# expression-in-a-group (without qualified-name)
- include: line-continuations
- include: illegal-assignment-expressions
- include: lambda-in-groups
- include: expressions-common
- include: illegal-name
- include: constants
# specific "qualified-name" patterns
- match: ({{identifier}})\s*({{assignment_operator}})
captures:
1: variable.parameter.class-inheritance.python
Expand All @@ -807,7 +812,6 @@ contexts:
push: qualified-base-class-name
- match: '{{identifier}}'
scope: entity.other.inherited-class.python
- include: expression-in-a-group

qualified-base-class-name:
- meta_scope: meta.path.python
Expand Down
33 changes: 33 additions & 0 deletions Python/tests/syntax_test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,39 @@ class DataClass(TypedDict, None, total=False, True=False):
# ^ invalid.illegal.assignment.python
# ^^^^^ constant.language.boolean.false.python

class MyClass(func(var, arg=var), module.func(var, arg=var)):
# ^^^^^^^ meta.class.python
# ^ meta.class.inheritance.python - meta.function-call
# ^^^^ meta.class.inheritance.python meta.function-call.identifier.python
# ^^^^^^^^^^^^^^ meta.class.inheritance.python meta.function-call.arguments.python
# ^^^^^^^^^ meta.class.inheritance.python - meta.function-call
# ^^^^ meta.class.inheritance.python meta.function-call.identifier.python
# ^^^^^^^^^^^^^^ meta.class.inheritance.python meta.function-call.arguments.python
# ^ meta.class.inheritance.python
# ^ meta.class.python
# ^^^^^^^ entity.name.class.python
# ^ punctuation.section.inheritance.begin.python
# ^^^^ variable.function.python
# ^ punctuation.section.arguments.begin.python
# ^^^ meta.generic-name.python
# ^ punctuation.separator.arguments.python
# ^^^ variable.parameter.python
# ^ keyword.operator.assignment.python
# ^^^ meta.generic-name.python
# ^ punctuation.section.arguments.end.python
# ^ punctuation.separator.inheritance.python
# ^^^^^^ meta.path.python meta.generic-name.python
# ^ meta.path.python punctuation.accessor.dot.python
# ^^^^ meta.path.python variable.function.python
# ^ punctuation.section.arguments.begin.python
# ^^^ meta.generic-name.python
# ^ punctuation.separator.arguments.python
# ^^^ variable.parameter.python
# ^ keyword.operator.assignment.python
# ^^^ meta.generic-name.python
# ^ punctuation.section.arguments.end.python
# ^ punctuation.section.inheritance.end.python
# ^ punctuation.section.class.begin.python

class MyClass:
def foo():
Expand Down