A flake8 extension to validate django models ForeignKey fields on on_delete CASCADE comment
Project description
flake8-django-on-delete-comment
A flake8 extension to validate django models ForeignKey fields on on_delete CASCADE comment.
test_field = models.ForeignKey( # allowed_cascade
'TestModel',
on_delete=models.CASCADE,
)
CASCADE can be not safe to choose, so such fields should be marked by comment.
Installation
pip install flake8-django-on-delete-comment
Example
Sample file:
# test.py
first_field = models.ForeignKey( # allowed_cascade
'FirstModel',
on_delete=models.CASCADE,
)
second_field = models.ForeignKey(
'SecondModel',
on_delete=models.CASCADE,
)
third_field = models.ForeignKey(
'ThirdModel',
on_delete=models.PROTECT,
)
Usage:
$ flake8 test.py
test.py:6:1: CD001 field needs a valid comment for on_delete
Contributing
We would love you to contribute to our project. It's simple:
- Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
- Create a pull request. Make sure all checks are green.
- Fix review comments if any.
- Be awesome.
Here are useful tips:
- You can run all checks and tests with
make check
. Please do it before TravisCI does. - We use BestDoctor python styleguide.
- We respect Django CoC. Make soft, not bullshit.
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
Close
Hashes for flake8_django_on_delete_comment-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20a8a20479cb168e981c5c1b6d46ce9545ff9c9dcebe6f59fb7ee45be677e5b0 |
|
MD5 | 85eb984d8dea5cba8707a6a6b055b548 |
|
BLAKE2b-256 | bd43bd81042da6bde0f78dab7a759e40b1398e247601ea7187ad64a80df69337 |