A flake8 plugin to detect issues with SQLAlchemy code
Project description
flake8-sqlalchemy
A flake8 plugin for SQLAlchemy code.
Installation
pip install flake8-sqlalchemy
Configuration
By default, all checks are enabled.
You can disable all checks by adding the following to your setup.cfg
:
[flake8]
ignore = SQA
or ignore specific checks:
[flake8]
ignore = SQA100
SQA100
- sqlalchemy
import alias
Checks that when sqlalchemy
is imported with an alias,
the alias is either sa
or db
.
Bad
import sqlalchemy as foo
Good
import sqlalchemy as sa
# or
import sqlalchemy as db
SQA200
- Column
keyword argument comment
required
When writing a Column
definition the comment
keyword argument is required.
This provides inline documentation for the column,
as well as generating the SQL to add the comment to the database.
Bad
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String)
Good
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, comment="User ID from Auth Service")
name = Column(String, comment="User name: first, middle, last")
Also applies to mapped_column
:
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, comment="User ID from Auth Service")
name = mapped_column(String, comment="User name: first, middle, last")
License
This project is licensed under the terms of the MIT license. See the LICENSE file for the full license text.
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8_sqlalchemy-0.2.0.tar.gz
.
File metadata
- Download URL: flake8_sqlalchemy-0.2.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0330865e8ea53c9da581283d960b91bf4716a467672d60a61433cbff202f884d |
|
MD5 | 0bc46945ba2e84f3b893b03dd6b72e42 |
|
BLAKE2b-256 | d8d6fe5646eb1c8e5f0260642128859195e6cc2ff7542356edeccebe90f63ef6 |
File details
Details for the file flake8_sqlalchemy-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_sqlalchemy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96c719d560f42857ef24fdb09b97a2e4acffbd40b6795f8bf26c01f2c109d50a |
|
MD5 | 842882859313049bfcf8e243d816da83 |
|
BLAKE2b-256 | 6cf4207e32a090d2304561aec4b39ebcfb8b00bfc22d31ed1f70e91e598c7fd6 |