microsoft / python-language-server

Microsoft Language Server for Python
Apache License 2.0
912 stars 133 forks source link

The message "unexpected token '['' appears in decorator. #2138

Closed thruc closed 3 years ago

thruc commented 3 years ago

Environment data

Expected behaviour

Do not display the message "unexpected token '['.

Code Snippet

The following code reproduces the issue:

def make_decorators():
    def decorator0(func):
        def inner_func0(*args):
            print('decorator 0')
            return func(*args)
        return inner_func0

    def decorator1(func):
        def inner_func1(*args):
            print('decorator 1')
            return func(*args)
        return inner_func1
    return [decorator0, decorator1]

decorators = make_decorators()

@decorators[0]
def hello():
    print('hello')

@decorators[1]
def goodbye():
    print('goodbye')

hello()
goodbye()

issue

gvanrossum commented 3 years ago

(Note that this is a new feature in Python 3.9, see PEP 614.)

jakebailey commented 3 years ago

The parser for MPLS would need to be updated for 3.9, something I don't know if we have the time to do. Pylance at least supports everything new in 3.9, if you haven't yet tried it.

thruc commented 3 years ago

@jakebailey Thank you for your reply. I have switched the language server to Pylance and confirmed that it does not happen .