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
I'm trying to use databricks-sql-python in a statically-typed python project, and I'm running into some issues. I'm using mypy --strict.
Despite this project having type annotations, my typechecker (mypy) will not check them (this causes problems for the type implications of the rest of my code). I'm pretty sure that, as per https://peps.python.org/pep-0561/#packaging-type-information, you can just add a py.typed file to the sql/ and sqlalchemy/ folders. I don't use the sqlalchemy side so I haven't tested that, but the sql one seems to work perfectly when I modify the copy of databricks-sql-python on my machine.
I get error: Call to untyped function "connect" in typed context [no-untyped-call]. I'm pretty sure you can just change the type signature of def connect in the sql folder's __init.py__ to def connect(server_hostname, http_path, access_token=None, **kwargs) -> "Connection". This works perfectly when I test it on my machine.
I get error: Returning Any from function declared to return "List[Row]" [no-any-return] when I have the line return cursor.execute(query, sql_params_dict).fetchall(). Honestly, I have no idea how to fix this. fetchall looks like it has the right type signature to me! Maybe this is a bug in mypy somehow? Or maybe this is a symptom of the previous issue not getting completely fixed...
I can make a pull request about this, at least the first two, but maybe these ideas are bad and you haven't done them yet because it would break something else; let me know!
The text was updated successfully, but these errors were encountered:
I'm trying to use databricks-sql-python in a statically-typed python project, and I'm running into some issues. I'm using
mypy --strict
.Despite this project having type annotations, my typechecker (mypy) will not check them (this causes problems for the type implications of the rest of my code). I'm pretty sure that, as per https://peps.python.org/pep-0561/#packaging-type-information, you can just add a py.typed file to the sql/ and sqlalchemy/ folders. I don't use the sqlalchemy side so I haven't tested that, but the sql one seems to work perfectly when I modify the copy of databricks-sql-python on my machine.
I get
error: Call to untyped function "connect" in typed context [no-untyped-call]
. I'm pretty sure you can just change the type signature ofdef connect
in the sql folder's__init.py__
todef connect(server_hostname, http_path, access_token=None, **kwargs) -> "Connection"
. This works perfectly when I test it on my machine.I get
error: Returning Any from function declared to return "List[Row]" [no-any-return]
when I have the linereturn cursor.execute(query, sql_params_dict).fetchall()
. Honestly, I have no idea how to fix this. fetchall looks like it has the right type signature to me! Maybe this is a bug in mypy somehow? Or maybe this is a symptom of the previous issue not getting completely fixed...I can make a pull request about this, at least the first two, but maybe these ideas are bad and you haven't done them yet because it would break something else; let me know!
The text was updated successfully, but these errors were encountered: