1

Below is the snippet from my python script which runs fine from pycharm but if run from Jenkins job's Execute shell the job is failing with error saying SyntaxError: invalid syntax at CURRENT_MONTH: Final = "cur_mon"

from typing import Final

CURRENT_MONTH: Final = "cur_mon"
LAST_MONTH: Final = "last_mon"
data_timeline = [CURRENT_MONTH, LAST_MONTH]

Command used in Jekins job is python my_file.py and pyhton3 my_file.py. In both cases it is failing with same error.

Please advise on what could be going wrong here.

1 Answer 1

1

Your Jenkins is running Python < 3.6. The variable annotation syntax came in Python 3.6:

https://www.python.org/dev/peps/pep-0526/

Also, Final got introduced in Python 3.8 (but missing it would of course raise an ImportError instead of a SyntaxError):

https://www.python.org/dev/peps/pep-0591/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.