breaks on type annotation for class attribute
dz0 opened this issue · 3 comments
class SimpleHttpTask(Task):
"""Very simple/naive"""
url = None
method = "GET"
client: requests.Session = requests.Session()
Pynsource couldn't handle traversing AST in file /Users/jpralgauskis/IdeaProjects/kettle/kettle/task/http.py corresponding to approx. lineno 18 coloffset 4 - source code:
client: requests.Session = requests.Session()
Please report this to https://github.com/abulka/pynsource/issues
Log file location:
/users/jpralgauskis/library/logs/pynsource/debug.log
debug.log
Actual exception:
'Attribute' object has no attribute 'id'
Thanks for reporting this - please try running the latest master using Python 3.8 or higher. I need to update the binary releases from Python 3.7 to Python 3.8 sometime.
@unittest.skipIf(sys.version_info.minor < 8, 'Need to upgrade Pynsource to run in Python 3.8 to handle this syntax')
def test_issue_class_type_annotation_85(self):
"""This seems to pass OK under Python 3.9
Hmm - perhaps this error only happens with lower version of
Python - will need to check. As it stands, it looks promising
that no changes to the Pynsource parser are needed,
only a Python version bump. That is, assuming the
source code reproduces the problem.
"""
source_code = dedent("""
class SimpleHttpTask(Task):
url = None
method = "GET"
client: requests.Session = requests.Session()
"""
)
pmodel, debuginfo = parse_source(source_code,
options={"mode": 3},
html_debug_root_name="test_issue_class_type_annotation_85")
self.assertNotIn("error", pmodel.errors)
Further testing is pending.
Latest master branch and 1.78 beta
binary release should have fixed this.
Official 1.78
release only a few days away.