madzak/python-json-logger

invalid syntax: RESERVED_ATTRS: Tuple[str, ...] = (

horaceleung opened this issue · 4 comments

We are deploying code that has a dependency on jsonlogger and it is now throwing the below syntax error. any help would be appreicated. (we are using python 3.5)

plugins_1 | from pythonjsonlogger import jsonlogger
plugins_1 | File "/usr/local/lib/python3.5/site-packages/pythonjsonlogger/jsonlogger.py", line 20
plugins_1 | RESERVED_ATTRS: Tuple[str, ...] = (
plugins_1 | ^
plugins_1 | SyntaxError: invalid syntax
drsuser_plugins_1 exited with code 1

What Python version are you running this?

Line 20 syntax was updated to support PEP 561 (https://peps.python.org/pep-0561/) which distributes types with the package, specifically here it's the ...: Tuple[str, ...] part, in this PR: 4c72bed

I'm running this on python 3.5 and haven't had this problem before on v2.0.2

The full log below:

plugins_1 | Traceback (most recent call last):
plugins_1 | File "/usr/local/bin/py-skygear", line 5, in
plugins_1 | from skygear.bin import main
plugins_1 | File "/usr/local/lib/python3.5/site-packages/skygear/init.py", line 24, in
plugins_1 | from .decorators import (
plugins_1 | File "/usr/local/lib/python3.5/site-packages/skygear/decorators.py", line 17, in
plugins_1 | from .registry import get_registry
plugins_1 | File "/usr/local/lib/python3.5/site-packages/skygear/registry.py", line 18, in
plugins_1 | from .utils.logging import setLoggerTag
plugins_1 | File "/usr/local/lib/python3.5/site-packages/skygear/utils/logging.py", line 17, in
plugins_1 | from pythonjsonlogger import jsonlogger
plugins_1 | File "/usr/local/lib/python3.5/site-packages/pythonjsonlogger/jsonlogger.py", line 20
plugins_1 | RESERVED_ATTRS: Tuple[str, ...] = (
plugins_1 | ^
plugins_1 | SyntaxError: invalid syntax

q0w commented

You should add from __future__ import annotations for older python versions
nvm: py35 support is dropped:

'Programming Language :: Python :: 3.6',

If you run into this on later versions feel free to re-open.