Skip to content

stubs use implicit reexports #187

Open
@rectalogic

Description

@rectalogic

Describe the bug
mypy enables --no-implicit-reexport for stub files:

Note this is always treated as enabled for stub files.

https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-no-implicit-reexport
Many of the sqlalchemy stubs reexport and so mypy seems to not recognize those exports.

Expected behavior
mypy should not fail

To Reproduce
cc.py:

import sqlalchemy

CC = sqlalchemy.sql.expression.ColumnClause

Error

$ mypy cc.py
cc.py:3: error: Module has no attribute "ColumnClause"
Found 1 error in 1 file (checked 1 source file)

Versions.

  • OS: Ubuntu 20.04
  • Python: 3.8.10
  • SQLAlchemy: 1.4.23
  • mypy: 0.910
  • SQLAlchemy2-stubs: 0.0.2a18

Additional context
Manually editing .../lib/python3.8/site-packages/sqlalchemy-stubs/sql/expression.pyi and changing the import of ColumnClause to from .elements import ColumnClause as ColumnClause fixes this.

There are other objects that are also implicitly re-exported and result in mypy errors - sqlalchemy.sql.expression.Executable, sqlalchemy.sql.expression.FunctionElement, sqlalchemy.sql.expression.Tuple etc.

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