{"id":15472491,"url":"https://github.com/miketheman/flake8-sqlalchemy","last_synced_at":"2025-04-09T17:04:54.724Z","repository":{"id":160111093,"uuid":"628274318","full_name":"miketheman/flake8-sqlalchemy","owner":"miketheman","description":"flake8-sqlalchemy","archived":false,"fork":false,"pushed_at":"2025-04-07T21:20:39.000Z","size":105,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T17:04:48.323Z","etag":null,"topics":["flake8","flake8-extension","flake8-extensions","flake8-plugin","flake8-plugins","lint","python","python3","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miketheman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-04-15T12:48:57.000Z","updated_at":"2025-04-07T21:20:40.000Z","dependencies_parsed_at":"2024-01-08T19:44:14.407Z","dependency_job_id":"bb44460e-bdd8-47e0-af8b-e8394546d2ce","html_url":"https://github.com/miketheman/flake8-sqlalchemy","commit_stats":{"total_commits":52,"total_committers":3,"mean_commits":"17.333333333333332","dds":0.3846153846153846,"last_synced_commit":"11c6351f2c4ead475ac40d4539942dbab61f9407"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketheman%2Fflake8-sqlalchemy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketheman%2Fflake8-sqlalchemy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketheman%2Fflake8-sqlalchemy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miketheman%2Fflake8-sqlalchemy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miketheman","download_url":"https://codeload.github.com/miketheman/flake8-sqlalchemy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074976,"owners_count":21043490,"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":["flake8","flake8-extension","flake8-extensions","flake8-plugin","flake8-plugins","lint","python","python3","sqlalchemy"],"created_at":"2024-10-02T02:39:04.930Z","updated_at":"2025-04-09T17:04:54.703Z","avatar_url":"https://github.com/miketheman.png","language":"Python","readme":"# flake8-sqlalchemy\n\n[![PyPI current version](https://img.shields.io/pypi/v/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)\n[![Python Support](https://img.shields.io/pypi/pyversions/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miketheman/flake8-sqlalchemy/main.svg)](https://results.pre-commit.ci/latest/github/miketheman/flake8-sqlalchemy/main)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nA flake8 plugin for SQLAlchemy code.\n\n## Installation\n\n```bash\npip install flake8-sqlalchemy\n```\n\n## Configuration\n\nBy default, all checks are enabled.\nYou can disable **all** checks by adding the following to your `setup.cfg`:\n\n```ini\n[flake8]\nignore = SQA\n```\n\nor ignore specific checks:\n\n```ini\n[flake8]\nignore = SQA100\n```\n\n### `SQA100` - `sqlalchemy` import alias\n\nChecks that when `sqlalchemy` is imported with an alias,\nthe alias is either `sa` or `db`.\n\n#### Bad\n\n```python\nimport sqlalchemy as foo\n```\n\n#### Good\n\n```python\nimport sqlalchemy as sa\n# or\nimport sqlalchemy as db\n```\n\n### `SQA200` - `Column` keyword argument `comment` required\n\nWhen writing a `Column` definition the `comment` keyword argument is required.\nThis provides inline documentation for the column,\nas well as generating the SQL to add the comment to the database.\n\n#### Bad\n\n```python\nclass Users(Base):\n    __tablename__ = \"users\"\n\n    id = Column(Integer, primary_key=True)\n    name = Column(String)\n```\n\n#### Good\n\n```python\nclass Users(Base):\n    __tablename__ = \"users\"\n\n    id = Column(Integer, primary_key=True, comment=\"User ID from Auth Service\")\n    name = Column(String, comment=\"User name: first, middle, last\")\n```\n\nAlso applies to `mapped_column`:\n\n```python\nclass Users(Base):\n    __tablename__ = \"users\"\n\n    id = Column(Integer, primary_key=True, comment=\"User ID from Auth Service\")\n    name = mapped_column(String, comment=\"User name: first, middle, last\")\n```\n\n### `SQA300` - Use `back_populates` instead of `backref` in relationship\n\nEncourages the use of `back_populates` instead of `backref` in SQLAlchemy relationships to ensure clarity and consistency in bidirectional relationships.\n\n#### Bad\n\n```python\nclass Parent(Base):\n    __tablename__ = \"parent\"\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", backref=\"parent\")\n```\n\n#### Good\n\n```python\nclass Parent(Base):\n    __tablename__ = \"parent\"\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = \"child\"\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey(\"parent.id\"))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\nSee the [LICENSE](LICENSE.md) file for the full license text.\n\n## Author\n\n- [Mike Fiedler](https://github.com/miketheman)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiketheman%2Fflake8-sqlalchemy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiketheman%2Fflake8-sqlalchemy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiketheman%2Fflake8-sqlalchemy/lists"}