sqlalchemy / sqlalchemy2-stubs

PEP-484 typing stubs for SQLAlchemy 1.4
MIT License
159 stars 41 forks source link

Incompatible type in `values` #228

Open mdczaplicki opened 2 years ago

mdczaplicki commented 2 years ago

Sorry, I don't have much time, but mypy screams here:

my_valyes = values(
    column("x", Integer),   # here
    column("y", Integer),  # and here
    name="my_values",
).data(my_values_data)

with:

error: Argument 1 to "Values" has incompatible type "ColumnClause[Integer]"; expected "Column[Any]"
error: Argument 2 to "Values" has incompatible type "ColumnClause[Integer]"; expected "Column[Any]"

stubs version 0.0.2a6

peterschutt commented 2 years ago

I tried to repro.

Env (also tried with 0.0.2a27):

(.venv) peter@peter-Inspiron-15-5510:~/PycharmProjects/sqla-stubs-228$ pip freeze
greenlet==1.1.3
mypy==0.971
mypy-extensions==0.4.3
SQLAlchemy==1.4.41
sqlalchemy2-stubs==0.0.2a26
tomli==2.0.1
typing_extensions==4.3.0

and

# main.py
from sqlalchemy import Integer, column, values

my_values = values(
    column("x", Integer),   # here
    column("y", Integer),  # and here
    name="my_values",
).data({})

reveal_type(my_values)

Result:

(.venv) peter@peter-Inspiron-15-5510:~/PycharmProjects/sqla-stubs-228$ mypy main.py 
main.py:9: note: Revealed type is "sqlalchemy.sql.selectable.Values"
Success: no issues found in 1 source file

The type of *columns param to Values changed from Column to ColumnClause[Any] in 0.0.2a12