andy-z / ged4py

GEDCOM tools for Python
MIT License
16 stars 7 forks source link

SyntaxError: invalid syntax : level: int for the class GedcomLine v0.4.0 Python2.7 #32

Closed Tuisto59 closed 3 years ago

Tuisto59 commented 3 years ago

Description

Import ged4py after installl it by pip on python2.7

What I Did

pip install ged4py

Python 2.7.17 (default, Nov  7 2019, 10:07:09) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ged4py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yoan/PycharmProjects/peregrination/venv/local/lib/python2.7/site-packages/ged4py/__init__.py", line 22, in <module>
    from .parser import GedcomReader  # noqa: F401
  File "/home/yoan/PycharmProjects/peregrination/venv/local/lib/python2.7/site-packages/ged4py/parser.py", line 45
    level: int
         ^
SyntaxError: invalid syntax

I see with PyCharm the same error. The error is underlined with "red" as an error of syntax in the class :

class GedcomLine(NamedTuple): """Class representing single line in a GEDCOM file.

.. note::

    Mostly for internal use by parser, most clients do not need to know
    about this class.

Attributes
----------
level : `int`
xref_id : `str`, possibly empty or ``None``
tag : `str`, required, non-empty
value : `bytes`, possibly empty or ``None``
offset : `int`
"""
level: int
"""Record level number (`int`)"""

xref_id: str
"""Reference for this record (`str` or ``None``)"""

tag: str
"""Tag name (`str`)"""

value: bytes
"""Record value (`bytes`)"""

offset: int
"""Record offset in a file (`int`)"""

The error found by PyCharm show that every: xxx: python_type

are underlined between the colon and the python type variable, saying that the "End of statement expected" , "Statement expected, found Py:COLON" for : level: int xref_id: str tag: str value: bytes offset: int

EDIT :

This annotation is for variable annotation come from python 3.6 with PEP526 , or it's not compatible with Python 2.7 so the error came because of that specific annotation from python3.5. I is possible to make a compatibility fix ?

Thanks for help !

EDIT 2 : My bad... I just see Python2 is no longer supported sorry - false alert.

andy-slac commented 3 years ago

Indeed, Python2 support has stopped with version 0.3. Latest release that has Python2 support is 0.2.4. All info is in History file.