Plugin to catch bad style specific to Django Projects.
Project description
flake8-django
A flake8 plugin to detect bad practices on Django projects.
Installation
Install from pip with:
$ pip install flake8-django
Testing
flake8-django uses pytest for tests. To run them use:
$ pytest
Run coverage report using:
$ pytest --cov=.
List of Rules
Rule | Description |
---|---|
DJ01 |
Avoid using null=True on string-based fields such as CharField and TextField |
DJ03 |
Avoid passing locals() as context to a render function |
DJ06 |
Do not use exclude with ModelForm, use fields instead |
DJ07 |
Do not use __all__ with ModelForm, use fields instead |
DJ08 |
Model does not define __str__ method |
DJ12 |
Order of Model's inner classes, methods, and fields does not follow the Django Style Guide |
DJ13 |
@receiver decorator must be on top of all the other decorators |
More details about each of the Rules can be found on the wiki page.
Optional Rules - Disabled by Default
Rule | Description |
---|---|
DJ10 |
Model should define verbose_name on its Meta inner class |
DJ11 |
Model should define verbose_name_plural on its Meta inner class |
To enable optional rules you can use the --select
parameter. It's default values are: E,F,W,C90.
For example, if you wanted to enable DJ10
, you could call flake8
in the following way:
flake8 --select=E,F,W,C90,DJ,DJ10
You could also add it to your configuration file:
[flake8]
max-line-length = 120
...
select = C,E,F,W,DJ,DJ10
Licence
GPL
Thanks
@stummjr for teaching me AST, and what I could do with it. His blog is cool.
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-django-1.1.4.tar.gz
.
File metadata
- Download URL: flake8-django-1.1.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/3.7.2 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66641a9aecf3786f6952a4e035c2a3e512c24e2d01134134598260987ba40abc |
|
MD5 | 2c32cf70ee597a61ad34d8d828f5121d |
|
BLAKE2b-256 | e9493c7240e1b3200be6cbb9296bee00cda89fdd36b81327e8b585d1b6e9c63f |
Provenance
File details
Details for the file flake8_django-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: flake8_django-1.1.4-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/3.7.2 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63c0db6e556a9457e6fe2b2a2d38a62491823afb8cd47bc18cea9ed463daf997 |
|
MD5 | 392f1f316c6100dc702b27b1d037c823 |
|
BLAKE2b-256 | 72c3d514563618d7c84a3563d615fdcbbc03e0e4005d6e29dd4bd707c0209e20 |