SNOW-874658: Type hints for execute and executemany in DictCursor is incorrect

Open
#1,663 3 comments 2 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Assessment

This issue has not been assessed yet.

Description

bug status-triage_done
Python version

Python 3.9.17

Operating system and processor architecture

macOS-13.4.1-arm64-arm-64bit

Installed packages
asn1crypto==1.5.1
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
cryptography==40.0.2
filelock==3.12.0
idna==3.4
oscrypto==1.3.0
packaging==23.1
pycparser==2.21
pycryptodomex==3.18.0
PyJWT==2.7.0
pyOpenSSL==23.1.1
pytz==2023.3
requests==2.31.0
snowflake-connector-python==3.0.4
sortedcontainers==2.4.0
typing_extensions==4.6.0
urllib3==1.26.16
What did you do?
# Write some code using execute or executemany and run mypy
#
# Like 


connection = snowflake.connector.connect(...)
with connection.cursor(DictCursor) as cur: # issue here too, as cursor always returns a SnowflakeCursor, this should be generified
    cur.execute("SELECT c1,c2 FROM example")
    results = cur.fetchall()
    for row in results:
       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

Dominant language
Python
Stars
730
Forks
574
Avg merge
5h 45m
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from snowflakedb/snowflake-connector-python

All issues in snowflakedb/snowflake-connector-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.