Skip to main content

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

Metadata

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)

Source distribution for flake8-forbidden-func 0.1.0
File Size Uploaded Provenance Actions
flake8_forbidden_func-0.1.0.tar.gz 7.6 kB Without provenance Details for flake8_forbidden_func-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flake8-forbidden-func 0.1.0
File Interpreter ABI Platform Actions
flake8_forbidden_func-0.1.0-py3-none-any.whl Python 3 none any Details for flake8_forbidden_func-0.1.0-py3-none-any.whl

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

Security for flake8-forbidden-func 0.1.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page