sqlalchemy2-stubs
sqlalchemy2-stubs copied to clipboard
sqlalchemy.func.* all infer to NullType
Describe the bug
When functions are called from the sqlalchemy.func import they are all of type sqlalchemy.sql.functions.Function[sqlalchemy.sql.sqltypes.NullType].
Expected behavior Have the same type when importing from:
sqlalchemy.funcsqlalchemy.sql.functions
To Reproduce Please try to provide a Minimal, Complete, and Verifiable example. See also Reporting Bugs on the website, and some example issues.
Please do not use Flask-SQLAlchemy or any other third-party extensions or dependencies in test cases. The test case must illustrate the problem without using any third party SQLAlchemy extensions. Otherwise, please report the bug to those projects first.
from sqlalchemy import func
from sqlalchemy.sql import functions
reveal_type(func.now())
reveal_type(functions.now())
Error
column_server_default_ticket_81.py:8: note: Revealed type is 'sqlalchemy.sql.functions.Function[sqlalchemy.sql.sqltypes.NullType]'
column_server_default_ticket_81.py:9: note: Revealed type is 'sqlalchemy.sql.functions.now[sqlalchemy.sql.sqltypes.DateTime]'
Have a nice day!
I think this is because _FunctionGenerator.__getattr__() needs to be typed better. I'm gonna have to look at what that's doing to get the function classes in the file before I propose a solution.