libcst.parse_module() raises an internal TypeError when parsing a Python file that contains both:
from __future__ import (absolute_import, division, print_function) (parenthesized import)
__metaclass__ = type on the immediately following line
import libcst as cst
source = """\
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
"""
cst.parse_module(source) # raises TypeError
Traceback (most recent call last):
File "reproduce.py", line 8, in <module>
cst.parse_module(source)
File ".../libcst/_parser/entrypoints.py", line 65, in parse_module
result = _parse(...)
File ".../libcst/_parser/entrypoints.py", line 47, in _parse
return parse(source_str)
File "<string>", line 6, in __init__
File ".../libcst/_nodes/base.py", line 118, in __post_init__
self._validate()
File ".../libcst/_nodes/statement.py", line 293, in _validate
if has_no_gap and not value._safe_to_use_with_word_operator(...)
File ".../libcst/_nodes/expression.py", line 2362, in _safe_to_use_with_word_operator
return super()._safe_to_use_with_word_operator(position)
TypeError: super(type, obj): obj must be an instance or subtype of type
libcst.parse_module() raises an internal TypeError when parsing a Python file that contains both:
Reproduce With:
Full Traceback: