Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixing a couple type problems. (adding py.typed, typing connect, returning Any from fetchall (which I failed to fix!)) #381

Closed
@wyattscarpenter

Description

@wyattscarpenter

I'm trying to use databricks-sql-python in a statically-typed python project, and I'm running into some issues. I'm usingmypy --strict.

  1. 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 perhttps://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.

  2. I geterror: 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.

  3. I geterror: 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp