2

I am dealing with some installation scripts from Github and am trying to execute this script which looks like it fails because of these lines:

current_app: 'PillarServer' = LocalProxy(_get_current_app)
"""the current app, annotated as PillarServer"""

Executing it with Python 3.5 returns this error:

$python main.py
  File "main.py", line 33
    current_app: 'PillarServer' = LocalProxy(_get_current_app)
               ^
SyntaxError: invalid syntax

Can anyone help me a bit here? I am not an expert in Python but am forced to use this script.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
71GA
  • 1,132
  • 6
  • 36
  • 69
  • 1
    That error is very descriptive. That is invalid syntax. Just look at how to declare variables in python to see that. – user3483203 Apr 05 '18 at 14:38
  • literally is just invalid variable assignment. what it says on the tin here bud. – L_Church Apr 05 '18 at 14:40
  • maybe it's meant to be something like `current_app = LocalProxy(_get_current_app())` since `_get_current_app` is a function? who knows – L_Church Apr 05 '18 at 14:41
  • 1
    Which version, exactly, are you using? Variable annotations, defined by [PEP-526](https://www.python.org/dev/peps/pep-0526/), weren't added until Python 3.6. – chepner Apr 05 '18 at 14:44
  • I am using 3.5. On Debian Stretch this is the highest it goes... – 71GA Apr 05 '18 at 14:49
  • 1
    The annotation looks somewhat gratuitous; you *might* be able to simply get rid of it if you have to use this code. `current_app = LocalProxy(...)`. (Annotations are supposed to be used only by static analyzers, not the script itself, but I haven't looked at the code closely.) – chepner Apr 05 '18 at 14:50
  • Related: https://stackoverflow.com/questions/39971929/what-are-variable-annotations-in-python-3-6 – mkrieger1 Apr 05 '18 at 14:57
  • @chepner Thank you for expanding my knowledge. – 71GA Apr 05 '18 at 15:16

1 Answers1

4

That's a PEP-526-style variable annotation. You appear to be running the code with an older version of Python; you need to use Python 3.6 or later to recognize that syntax.

chepner
  • 497,756
  • 71
  • 530
  • 681