SyntaxError when importing AthenaDialect
rajeee opened this issue · 5 comments
I get the following error when importing AthenaDialect in version 3.0.7
>>> from pyathena.sqlalchemy.base import AthenaDialect
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/radhikar/mambaforge/envs/largeee/lib/python3.11/site-packages/pyathena/sqlalchemy/base.py", line 907, in <module>
class AthenaDialect(DefaultDialect):
File "/Users/radhikar/mambaforge/envs/largeee/lib/python3.11/site-packages/pyathena/sqlalchemy/base.py", line 1105, in AthenaDialect
@reflection.cache
^^^^^^^^^^^^^^^^
File "/Users/radhikar/mambaforge/envs/largeee/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 198, in decorate
decorated = _exec_code_in_env(code, env, fn.__name__)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/radhikar/mambaforge/envs/largeee/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 228, in _exec_code_in_env
exec(code, env)
File "<string>", line 1
def get_view_definition(self, connection: 'Connection', view_name: 'str', schema: 'Optional[str]'=None, **kw) -> 'str):
^
SyntaxError: unterminated string literal (detected at line 1)
Version 3.0.6 works fine.
Strange, all tests pass.
https://github.com/laughingman7743/PyAthena/actions/runs/6242621017
What version of SQLAlchemy are you using?
https://github.com/laughingman7743/PyAthena/blob/v3.0.7/pyathena/sqlalchemy/base.py#L1108
It seems that an error is occurring with this type hint, so it may be possible to remove this type hint. I don't think the type hint is required.
I'm having this issue with SQLAlchemy 1.4.49.
I have confirmed that the error occurs in SQLAlchemy 1.x. I will fix it.
Awesome, thanks @laughingman7743!
FWIW I found this commit sqlalchemy/sqlalchemy@91501e0 which alludes to the cause of this issue:
Additionally, to support annotations for methods that
make use of@decorator
,@Generative
etc., modified
format_argspec_plus
to no longer return "args", instead
returns "grouped_args" which is always grouped and
allows return annotations to format correctly.
This seems to be relevant since AthenaDialect.get_view_definition()
is decorated with @sqlalchemy.engine.reflection.cache
.