You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Write some code using execute or executemany and run mypy## Like connection=snowflake.connector.connect(...)
withconnection.cursor(DictCursor) ascur: # issue here too, as cursor always returns a SnowflakeCursor, this should be generifiedcur.execute("SELECT c1,c2 FROM example")
results=cur.fetchall()
forrowinresults:
c1=row["C1"] # error here, as SnowflakeCursor marks return type as list# The issue stems from DictCursor not defining overrides correctly.
What did you expect to see?
No mypy errors
Can you set logging to DEBUG and collect the logs?
No response
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Type hints for execute and executemany in DictCursor is incorrect
SNOW-874658: Type hints for execute and executemany in DictCursor is incorrect
Jul 24, 2023
error: No overload variant of "__getitem__" of "tuple" matches argument type "str" [call-overload]
note: Possible overload variants:
note: def __getitem__(self, SupportsIndex, /) -> Any
note: def __getitem__(self, slice, /) -> tuple[Any, ...]
error: Value of type "dict[Any, Any] | tuple[Any, ...] | None" is not indexable [index]
So yeah the issue for me is that we can't specify with DictCursor that the internal _result field is going to be a dictionary. Is this getting worked on?
hi and thank you for raising this ! i understand this is still an issue and definitely needs to be addressed somehow. we'll take a look and I'll keep this thread posted with new information.
Python version
Python 3.9.17
Operating system and processor architecture
macOS-13.4.1-arm64-arm-64bit
Installed packages
What did you do?
What did you expect to see?
No mypy errors
Can you set logging to DEBUG and collect the logs?
No response
The text was updated successfully, but these errors were encountered: