Skip to content

Proper type hint of Cursor.execute parameters #391

@rob975

Description

@rob975

Below function works fine but I get an error from Mypy saying parameters type, Optional[dict], is not compatible with Union[dict, list, tuple].

def dummy(cursor: Cursor, parameters: dict | None) -> None:
    for row in cursor.execute("select current_date from dual", parameters):
        print(row[0])

Given parameters defaults to None, I believe type hint should include None too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions