FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

psycopg2: RealDictCursor cursor is type checking as untyped · Issue #14417 · python/typeshed · GitHub

Repository navigation

psycopg2: RealDictCursor cursor is type checking as untyped #14417

Closed as not planned

Description

Problem

cursors using the RealDictCursor cursor factory are being caught as untyped in mypy strict mode.

Versions

mypy==1.17.0
psycopg2==2.9.10
types-psycopg2==2.9.21.20250516

Issue not present in types-psycopg2==2.9.21.20250318 and still "reveals" as Any

Replication

Save the below script

import psycopg2
from psycopg2.extras import RealDictCursor


def main(conn: psycopg2.extensions.connection) -> None:
    with conn.cursor(cursor_factory=RealDictCursor) as cursor:
        reveal_type(cursor.execute("SELECT * FROM users"))

run mypy --strict

↳ mypy --strict .
main.py:7: error: Call to untyped function "execute" in typed context  [no-untyped-call]
main.py:7: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file)

Activity

  1. added
    stubs: incompleteAnnotations or sub-modules missing from an existing package or module
    on Jul 16, 2025
  2. srittau commented on Jul 16, 2025

    Collaborator

    Yes, RealDictCursor.execute() is untyped in typeshed. We don't keep issues about untyped items open in typeshed, as this is a rather frequent and "expected" situation. That said, PRs that add or fix annotations are always welcome!

  3. Don-Burns commented on Jul 16, 2025

    ContributorAuthor

    Understood. I only raised it as previously "ok" code is now not safely checking on the newer version, since whatever changed now surfaces an untyped func rather than a func returning Any.
    Of course the Any is a "lie" too.

  4. srittau commented on Jul 16, 2025

    Collaborator

    The issue was probably hidden before #14063 since vars was previously annotated as Incomplete | None = None, which made type checkers believe that execute was partly annotated (when it wasn't really).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL