An extension for flake8 that forbids some functions in some modules.
Project description
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 |
Project details
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_forbidden_func-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8842da375e1e74622082738d251c1ce3d32900dac3bdd6d318058ffc4dbd47a |
|
MD5 | 8d8b0c649e82d0880f062af50fc1560e |
|
BLAKE2b-256 | b3c5daa1f55fd58e604ab9c99c009becaba50bd5e96bc0740ff1acad4e7e47b2 |
Close
Hashes for flake8_forbidden_func-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 082cda08bbf09f2bd53e741a6cfeb0cece72f49b251e8cb2e53e7bb8258dd179 |
|
MD5 | d84e2490328f583cac57c42a0fba2079 |
|
BLAKE2b-256 | d22d30b08fc881fbf9609ddd15ae233e952009500974019f389de671125268e9 |