flake8-forbidden-func
An extension for flake8 that forbids some functions in some modules.
Installation
pip install flake8-forbidden-func
Example
# users/views.py
from users import User
import datetime
def test_view():
print(datetime.datetime.now())
faz = User.objects.all().annotate().filter(a=2)
baz = bar_func()
if faz == baz:
fuz = q.filter(a=1)
return fuz.bar()
# setup.cfg
[flake8]
forbidden-functions =
*.views: *.filter, views module should not use ORM filter
*: datetime.datetime.now, we use django utils
allowed-functions =
*.selectors: *.objects.*, only selectors module should use ORM
Usage:
$ flake8 users/views.py
users/views.py:6:11: CFF001 datetime.datetime.now call is forbidden,since we use django utils.
users/views.py:7:11: CFF001 *.objects.* call is forbidden, since only selectors module should use ORM.
users/views.py:7:11: CFF001 *.objects.* call is forbidden, since only selectors module should use ORM.
users/views.py:7:11: CFF001 *.objects.* call is forbidden, since only selectors module should use ORM.
users/views.py:11:15: CFF001 *.filter call is forbidden, since views module should not use ORM filter.
Tested on Python 3.7+ and flake8 4.0+.
Error codes
| Error code | Description |
|---|---|
| CFF001 | call is forbidden, since reason |
| CFF000 | happens when we get unhandled exception during the linting process |
Release files for flake8-forbidden-func 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8_forbidden_func-0.1.0.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_forbidden_func-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / flake8_forbidden_func-0.1.0.tar.gz
| Download URL | flake8_forbidden_func-0.1.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af382edab9f034e6616d8d94a8cdd3df4a4a0809855badbc7253f3f94527de2d
|
|
BLAKE2b-256 checksum How to use checksums |
16a4f1d79aa5a6c6f37b3af030b48ff882cfa839902416d4a6b5b917c70cf576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Release files / flake8_forbidden_func-0.1.0-py3-none-any.whl
| Download URL | flake8_forbidden_func-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b918cef1aef2636fcd4fe629e05c5d5e32543851bed3026abcbd489d9a7f71f
|
|
BLAKE2b-256 checksum How to use checksums |
2160d47e5332059af574d40a096861d1f429adc9d0766f916ad483721d492594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|