Closed woosuk-choi-g closed 8 months ago
Thank you for your contribution. I have made some comments, please check them out.
Now, the type analyzer can accurately infer the Cursor type of Connection.
# reveal_type.py
connection_aysnc_cursor = connect(cursor_class=AsyncCursor)
reveal_type(connection_aysnc_cursor)
aysnc_cursor = connection_aysnc_cursor.cursor()
reveal_type(aysnc_cursor)
dict_cursor = connection_aysnc_cursor.cursor(DictCursor)
reveal_type(dict_cursor)
connection_cursor = Connection()
reveal_type(connection_cursor)
cursor = connection_cursor.cursor()
reveal_type(cursor)
connection_async = Connection(cursor_class=AsyncCursor)
reveal_type(connection_async)
async_cursor = connection_async.cursor()
reveal_type(async_cursor)
dict_cursor = connection_async.cursor(DictCursor)
reveal_type(dict_cursor)
$ mypy reveal_type.py
.vscode\main.py:8: note: Revealed type is "pyathena.connection.Connection[pyathena.async_cursor.AsyncCursor]"
.vscode\main.py:11: note: Revealed type is "pyathena.async_cursor.AsyncCursor"
.vscode\main.py:14: note: Revealed type is "pyathena.cursor.DictCursor"
.vscode\main.py:17: note: Revealed type is "pyathena.connection.Connection[pyathena.cursor.Cursor]"
.vscode\main.py:20: note: Revealed type is "pyathena.cursor.Cursor"
.vscode\main.py:23: note: Revealed type is "pyathena.connection.Connection[pyathena.async_cursor.AsyncCursor]"
.vscode\main.py:26: note: Revealed type is "pyathena.async_cursor.AsyncCursor"
.vscode\main.py:29: note: Revealed type is "pyathena.cursor.DictCursor"
and fixed formatting error 😊
$ mypy .
Success: no issues found in 40 source files
I just released v3.2.0. 🎉 https://pypi.org/project/PyAthena/3.2.0/ https://github.com/laughingman7743/PyAthena/releases/tag/v3.2.0
@woosuk-choi-g Please check the following issues: https://github.com/laughingman7743/PyAthena/issues/506
Related Issue
484
Overview
Enhances type inference capabilities. While there may be no significant impact in some use cases, it is better compared to before.
Use Case
Limitation
def connection
factory method still not support type hint