Django linter
This is a simple extension for pylint that aims to check some common mistakes in django projects.
Contributions are welcome.
Installation
pip install django_linter
Usage
It can be used as a plugin or standalone script. To use it as a plugin it should be installed first, then run with pylint:
pylint --load-plugins=django_linter TARGET
To use it as a standalone script:
usage: django-linter [-h] TARGET [TARGET ...] Simple extension for pylint to check django projects for common mistakes. positional arguments: TARGET python package or module optional arguments: -h, --help show this help message and exit
Implemented checks
Settings:
E5221 (required-setting-missed): Used when required setting missed in settings file.
E5222 (empty-setting): Used when setting is empty value.
W5221 (improper-settings-import): Used when settings is not imported from django.conf
Models:
W5241 (nullable-text-field): Used when text field has null=True.
W5242 (float-money-field): Used when money related field uses FloatField.
W5243 (naive-datetime-used): Used when there is datetime.now is used.
W5244 (related-field-named-with-id): Used when related field is named with _id suffix
W5245 (unicode-method-absent): Used when model has no unicode method.
W5246 (unicode-method-return): Used when unicode method does not return unicode.
W5247 (model-field-redefinition): Used when there are more than one model field with the same name.
W5248 (get-absolute-url-without-reverse): Used when get_absolute_url method is defined without using reverse function.
Forms:
W5211 (form-field-redefinition): Used when there are more than one form field with the same name.
Views:
W5231 (is-authenticated-not-called): Used when is_authenticated method is not called
W5232 (objects-get-without-doesnotexist): Used when Model.objects.get is used without enclosing it in try-except block to catch DoesNotExist exception.
W5233 (fetching-db-objects-len): Used when there is db query that fetches objects from database only to check the number of returned objects.
W5234 (raw-get-post-access): Used when request.GET or request.POST dicts is accessed directly, it is better to use forms.
Layout:
W5201 (forms-layout): Used when form class definition is not in forms module.
W5202 (admin-layout): Used when admin class definition is not in admin module.
Misc:
W5251 (print-used): Used when there is print statement or function
Implemented suppressers
“Meta” classes
urlpatterns
logger
Implemented transformers
Models
“id” field
“objects” manager
“DoesNotExist” exception
“MultipleObjectsReturned” exception
Testing
test responses (django and DRF)
Factories
factory-boy’s factories (factory should return django model, but not always possible to infer model class)
Metadata
Release files for django_linter 0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_linter-0.7.tar.gz | 9.2 kB | Without provenance | Details for django_linter-0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_linter-0.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_linter-0.7-py2.py3-none-any.whl |
Total release size: 26.0 kB
Release files / django_linter-0.7.tar.gz
| Download URL | django_linter-0.7.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
543bfe9f8eb11d3ff56fc6575864dd7dad8af60cd4eab0ecf6b1def220d52c87
|
|
BLAKE2b-256 checksum How to use checksums |
8adff41bfa5f636db0ce9cfe9d3ddbbb06b224ceffe9162e6ccc6fbe9793964d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_linter-0.7-py2.py3-none-any.whl
| Download URL | django_linter-0.7-py2.py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
60b7b31ac84a806744607751cb925504060b6b211c42bd9e35bd7047505e70e4
|
|
BLAKE2b-256 checksum How to use checksums |
dbed53eff23664ea5cec20d24e5419f342cc81486ecf6d4133106c61c03030ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django_linter 0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.