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 CI 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
Built Distribution
Close
Hashes for flake8_django_on_delete_comment-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a47c667f9189421023ac873ec0b3cba12b06a4a28f6979615ab334f12e356a05 |
|
MD5 | b8e5fca5a693d57951665ec48f7cfdfc |
|
BLAKE2b-256 | f6e1ff11d749c738e70e97f834f5cd05cd9f244471269808d29994520782f01d |
Close
Hashes for flake8_django_on_delete_comment-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2643086ef01320bb3e6a37f25e2b93eb31d910db73ae9c3808a64cfa3016b190 |
|
MD5 | 9ad1b60e32cffd30b870d0bb13bc0de0 |
|
BLAKE2b-256 | 42482e4d36d83cd47f81e8ee8d3e468c540bd5b55b5fdaf5c9703838a904a8ad |