Skip to content

Type annotation for executemany seq_of_parameters invalid for pyformat style #469

Closed

Description

Describe the bug

The type annotation for seq_of_parameters in Cursor.executemany does not appear to be correct for the pyformat style where seq_of_parameters might be a list of dicts/mappings with parameter names as keys.

To reproduce

Using pyright as a typechecker:

query = "..."
params: list[dict[str, Any]] = [{"param1": "foo", "param2": "bar"}]
cursor.executemany(query, params) # pyright error: "Argument of type "list[dict[str, Any]]" cannot be assigned to parameter "seq_of_parameters" of type "List[Sequence[Any]]" in function "executemany""
from collections.abc import Sequence
params = {"foo": "bar"}
print(isinstance(params, Sequence)) # False

Expected behavior

executemany should accept any seq_of_params that matches the shape [{"key": <value>}]. Something like List[Sequence[Any]] | List[Mapping[str, Any]] or List[Sequence[Any]] | List[Dict[str, Any]]

Further technical details

Python version: 3.12.12
Operating system: MacOS 26.2
Pyright version: 1.1.408

Additional context

Though dict does implement the __getitem__ and __len__ methods of the Sequence protocol, it is not technically a Sequence (see PySequence_Check as well as the isinstance check shown above)

Not that big of a deal in the grand scheme of things but would be nice to avoid having to put "#pyright: ignore[reportArgumentType]" in calling code. Happy to submit a PR for this too, but wanted to submit the issue first.

Activity

  1. github-actions commented on Mar 6, 2026

    @github-actions

    Hi Zachary Eller (@zacharyeller13), thank you for opening this issue!

    Our team will review it shortly. We aim to triage all new issues within 24-48 hours and get back to you.

    If you have additional information to share, please feel free to update the issue.

    Thank you for your patience!

  2. bewithgaurav commented on Mar 17, 2026

    @bewithgaurav
    Collaborator

    Hi Zachary Eller (@zacharyeller13) - Thanks a lot for raising the issue and posting all the details.
    We've triaged this is a bug in our typing declaration - and we'll post if anything else is needed from your end.
    Thanks again, we'll keep the issue posted as we go ahead to fix this.

  3. added
    bugSomething isn't working
    triage doneIssues that are triaged by dev team and are in investigation.
    and removed
    triage neededFor new issues, not triaged yet.
    on Mar 17, 2026
  4. added 2 commits that reference this issue on Apr 15, 2026
    da087fd
    c2007c9
  5. bewithgaurav commented on Apr 29, 2026

    @bewithgaurav
    Collaborator

    Zachary Eller (@zacharyeller13) - this is now fixed and shipped with our latest release (v1.6.0)
    please check and let us know if issue persists - closing this for now
    thanks for raising this issue! :)

  6. added
    communityPR or Issue raised by community members
    and removed
    triage doneIssues that are triaged by dev team and are in investigation.
    on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

FIXEDarea: api-compliancePython API behavior and typing: DB-API 2.0, exceptions, type stubs, new APIs.bugSomething isn't workingcommunityPR or Issue raised by community membersinADO

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions