rtts / djhtml

Django/Jinja template indenter
GNU General Public License v3.0
582 stars 32 forks source link

Incompatibility with python < 3.8 #26

Closed Djailla closed 3 years ago

Djailla commented 3 years ago

Hello, the walrus operator has been introduced in Python 3.8 thus, djhtml does not work with older "supported" version of Python


  File "/Users/b.vallet/Workspace/python-projects/dcma/.venv/bin/djhtml", line 5, in <module>
    from djhtml.__main__ import main
  File "/Users/b.vallet/Workspace/python-projects/dcma/.venv/lib/python3.6/site-packages/djhtml/__main__.py", line 4, in <module>
    from . import modes
  File "/Users/b.vallet/Workspace/python-projects/dcma/.venv/lib/python3.6/site-packages/djhtml/modes.py", line 152
    if tag := re.match(r"{% *(\w+).*?%}", raw_token):
            ^
SyntaxError: invalid syntax```
JaapJoris commented 3 years ago

Yes, you're right. I really like the "Walrus operator" but it requires Python 3.8. For now, I'll update setup.cfg to include the python_requires argument. But if anyone is willing to audit the code for backwards compatibility I'll be happy to accept a PR!