Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datetime desc in Index results in arg-type error #82

Closed
9dogs opened this issue Apr 30, 2021 · 3 comments · Fixed by #108
Closed

Datetime desc in Index results in arg-type error #82

9dogs opened this issue Apr 30, 2021 · 3 comments · Fixed by #108
Labels
bug Something isn't working

Comments

@9dogs
Copy link

9dogs commented Apr 30, 2021

Describe the bug
mypy reports an error when datetime_col.desc() is used as an Index second argument; datetime_col (without desc) works as intended.

Expected behavior
mypy does not produce an error

To Reproduce

from sqlalchemy import Column, DateTime, Integer, Index
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class Model(Base):
    
    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime)

    __tablename__ = 'model'
    __table_args__ = (
        # error: Argument 2 to "Index" has incompatible type "ClauseElement"; expected "ColumnClause[Any]"  [arg-type]
        Index('created_at_idx', created_at.desc()),
    )

Error

error: Argument 2 to "Index" has incompatible type "ClauseElement"; expected "ColumnClause[Any]"  [arg-type]

Versions.

  • OS: dockerized python:3.9.4-buster
  • Python: 3.9.4
  • SQLAlchemy: 1.4.12

Have a nice day!

@9dogs 9dogs added the requires triage New issue that requires categorization label Apr 30, 2021
@CaselIT
Copy link
Member

CaselIT commented May 5, 2021

Thanks for reporting

@bryanforbes was this fixed by #69?

@CaselIT CaselIT added bug Something isn't working and removed requires triage New issue that requires categorization labels May 5, 2021
@bryanforbes
Copy link
Contributor

I don't think this is fixed

@MaicoTimmerman
Copy link
Contributor

I think this is fixable by making ColumnOperators generic and letting the functions return ColumnElement[_T]. I've tried looking, but is there any use-case in which the ColumnOperators functions must return a ClauseElement as they currently do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants