sqlalchemy / sqlalchemy2-stubs

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

Using compiles leads to untyped decorator #239

Open kasium opened 2 years ago

kasium commented 2 years ago

Describe the bug The compile decorator is not fully typed. Therefore mypy complains when using it

Expected behavior Mypy doesn't complain

To Reproduce Use compile as a decorator

Error

error: Untyped decorator makes function "foo" untyped  [misc]

Versions.

I'm happy to give a PR a try

verhovensky commented 9 months ago

Facing same issue


@compiles(Utcnow, 'postgresql')
def pg_utcnow(element, compiler, **kw):
    return "TIMEZONE('utc', CURRENT_TIMESTAMP)"

@compiles(Utcnow, 'mssql')
def ms_utcnow(element, compiler, **kw):
    return 'GETUTCDATE()'