An extension for flake8 that forbids some imports statements in some modules.
Project description
flake8-obey-import-goat
An extension for flake8 that forbids some imports statements in some modules.
Important: this project is developed using DDD, so some of the docs can not exists. Stay tuned :)
Installation
pip install flake8-obey-import-goat
Example
# foo.py
from datetime import datetime
from typing import Optional
def foo():
pass
# users/bar.py
from foo import foo
# setup.cfg
[flake8]
forbidden-imports =
*: datetime.datetime, stdlib modules should be imported as a module
*: typing.Optional, we use T | None instead of Optional[T]
users.*: foo.*, users module should not use foo module
Usage:
$ flake8 test.py
foo.py:1:1: OIG001 datetime.datetime is forbidden, since stdlib modules should be imported as a module.
foo.py:2:1: OIG001 typing.Optional is forbidden, since we use T | None instead of Optional[T].
users/bar.py:1:1: OIG001 foo.foo import is forbidden is forbidden, since users module should not use foo module.
Tested on Python 3.9+ and flake8 4.0+.
Error codes
Error code | Description |
---|---|
OIG001 | importable is forbidden, since reason |
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
Close
Hashes for flake8_obey_import_goat-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf6170609d2ce5616b74614ff42890cbf3a5fc2b660eaa01b6a8682c9066980e |
|
MD5 | 59f88df985d001b4dff83cf6d90620ce |
|
BLAKE2b-256 | ad669410ad5277e606965986839b1162d2f482704f1005220e6ec3a1c82267c1 |