Skip to content

psycopg2 stubs do not explicitly export anything and so can't be used for typechecking #12578

@sh-at-cs

Description

@sh-at-cs

Steps to reproduce

  1. Create a new venv and install the relevant packages: pip3 install mypy psycopg2 types-psycopg2
  2. Create a file example.py containing from psycopg2 import cursor
  3. Typecheck this file with Mypy: mypy example.py

This will result in the following error:

example.py:1: error: Module "psycopg2" does not explicitly export attribute "cursor"  [attr-defined]

Suggested fix

Apparently, recent versions of Mypy need stub definitions to be explicitly exported via __all__, but this is missing from the psycopg2 stubs. So it's probably just to add those?

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: improvementImprove/refactor existing annotations, other stubs issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions