This package contains type stubs and soon a mypy plugin to provide more precise static types and type inference for SQLAlchemy framework. SQLAlchemy uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns. A simple example:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
user: User
user.id # Inferred type is "int"
User.name # Inferred type is "Column[str]"
To install the latest version of the package:
git clone https://github.com/dropbox/sqlalchemy-stubs
cd sqlalchemy-stubs
pip install -U .
After the 0.1 version will be released on PyPI, one can install latest stable version as:
pip install -U sqlalchemy-stubs
The package is currently in pre-alpha stage. See issue tracker
for bugs and missing features. If you want to contribute, a good place to start is
help-wanted
label.
The 0.1 version will be released after we will fix issues #2, #5, and #7. The long term goal is to be able to infer types for more complex situations like correctly inferring columns in most compound queries.
External contributions to the project should be subject to Dropbox Contributor License Agreement (CLA).
Copyright (c) 2018 Dropbox, Inc.