{"id":13800275,"url":"https://github.com/dropbox/sqlalchemy-stubs","last_synced_at":"2025-05-14T20:10:13.096Z","repository":{"id":33814539,"uuid":"143896266","full_name":"dropbox/sqlalchemy-stubs","owner":"dropbox","description":"Mypy plugin and stubs for SQLAlchemy","archived":false,"fork":false,"pushed_at":"2024-06-10T23:08:27.000Z","size":286,"stargazers_count":574,"open_issues_count":88,"forks_count":100,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-05-13T18:47:29.397Z","etag":null,"topics":["mypy","python","sql","sqlalchemy","stubs","types","typing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dropbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-07T15:54:48.000Z","updated_at":"2025-05-03T15:54:28.000Z","dependencies_parsed_at":"2024-11-18T15:52:29.814Z","dependency_job_id":null,"html_url":"https://github.com/dropbox/sqlalchemy-stubs","commit_stats":{"total_commits":141,"total_committers":35,"mean_commits":"4.0285714285714285","dds":0.7092198581560284,"last_synced_commit":"ed9611114925f4b2aea42401217c0eacb1a564e1"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fsqlalchemy-stubs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fsqlalchemy-stubs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fsqlalchemy-stubs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dropbox%2Fsqlalchemy-stubs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dropbox","download_url":"https://codeload.github.com/dropbox/sqlalchemy-stubs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219374,"owners_count":22034397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mypy","python","sql","sqlalchemy","stubs","types","typing"],"created_at":"2024-08-04T00:01:11.023Z","updated_at":"2025-05-14T20:10:13.069Z","avatar_url":"https://github.com/dropbox.png","language":"Python","readme":"\u003cimg src=\"http://mypy-lang.org/static/mypy_light.svg\" alt=\"mypy logo\" width=\"300px\"/\u003e\n\nMypy plugin and stubs for SQLAlchemy\n====================================\n\n[![Build Status](https://travis-ci.org/dropbox/sqlalchemy-stubs.svg?branch=master)](https://travis-ci.org/dropbox/sqlalchemy-stubs)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n\nThis package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) and a\n[mypy plugin](https://mypy.readthedocs.io/en/latest/extending_mypy.html#extending-mypy-using-plugins)\nto provide more precise static types and type inference for\n[SQLAlchemy framework](http://docs.sqlalchemy.org/en/latest/). SQLAlchemy uses some\nPython \"magic\" that makes having precise types for some code patterns problematic.\nThis is why we need to accompany the stubs with mypy plugins. The final goal is to\nbe able to get precise types for most common patterns. Currently, basic operations\nwith models are supported. A simple example:\n```python\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy import Column, Integer, String\n\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(String)\n\nuser = User(id=42, name=42)  # Error: Incompatible type for \"name\" of \"User\"\n                             # (got \"int\", expected \"Optional[str]\")\nuser.id  # Inferred type is \"int\"\nUser.name  # Inferred type is \"Column[Optional[str]]\"\n```\n\nSome auto-generated attributes are added to models. Simple relationships\nare supported but require models to be imported:\n```python\nfrom typing import TYPE_CHECKING\nif TYPE_CHECKING:\n    from models.address import Address\n\n...\n\nclass User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(String)\n    address = relationship('Address')  # OK, mypy understands string references.\n```\n\nThe next step is to support precise types for table definitions (e.g.\ninferring `Column[Optional[str]]` for `users.c.name`, currently it is just\n`Column[Any]`), and precise types for results of queries made using `query()`\nand `select()`.\n\n## Installation\nInstall latest published version as:\n```\npip install -U sqlalchemy-stubs\n```\n\n*Important*: you need to enable the plugin in your mypy config file:\n```\n[mypy]\nplugins = sqlmypy\n```\n\nTo install the development version of the package:\n```\ngit clone https://github.com/dropbox/sqlalchemy-stubs\ncd sqlalchemy-stubs\npip install -U .\n```\n\n## Development Setup\n\nFirst, clone the repo and cd into it, like in _Installation_, then:\n```\ngit submodule update --init --recursive\npip install -r dev-requirements.txt\n```\n\nThen, to run the tests, simply:\n```\npytest\n```\n\n## Development status\n\nThe package is currently in alpha stage. See [issue tracker](https://github.com/dropbox/sqlalchemy-stubs/issues)\nfor bugs and missing features. If you want to contribute, a good place to start is\n[`help-wanted` label](https://github.com/dropbox/sqlalchemy-stubs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).\n\nCurrently, some basic use cases like inferring model field types are supported.\nThe long term goal is to be able to infer types for more complex situations\nlike correctly inferring columns in most compound queries.\n\nExternal contributions to the project should be subject to\n[Dropbox Contributor License Agreement (CLA)](https://opensource.dropbox.com/cla/).\n\n--------------------------------\nCopyright (c) 2018 Dropbox, Inc.\n","funding_links":[],"categories":["Stub packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fsqlalchemy-stubs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdropbox%2Fsqlalchemy-stubs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdropbox%2Fsqlalchemy-stubs/lists"}