flake8的一个扩展,禁止某些模块中的某些导入语句。
项目描述
flake8-obey-import-goat
flake8的一个扩展,禁止某些模块中的某些导入语句。
重要:该项目使用DDD开发,因此部分文档可能不存在。请保持关注 :)
安装
pip install flake8-obey-import-goat
示例
# foo.py
from datetime import datetime
from typing import Optional
def foo():
pass
# users/bar.py
from foo import foo
# users/domain.py
def foo():
pass
# users/implementation.py
from users.domain import foo
# orders/implementation.py
from users.domain 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
*.implementation.*: *.domain.*, implementation layer should not use domain layer
用法
$ 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.
users/implementation.py:1:1: OIG001 *.domain.* import is forbidden is forbidden, since implementation layer should not use domain layer.
orders/implementation.py:1:1: OIG001 *.domain.* import is forbidden is forbidden, since implementation layer should not use domain layer.
在Python 3.9+和flake8 4.0+上测试过。
错误代码
错误代码 | 描述 |
---|---|
OIG001 | importable被禁止,因为 |
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装软件包 的更多信息。
源分布
flake8_obey_import_goat-0.1.1.tar.gz (4.3 kB 查看散列)
关闭
flake8_obey_import_goat-0.1.1.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 2e4c7be21b96dda72e903c21de16ff928e11fccdf9427889bfb7ccf4610f6072 |
|
MD5 | 52117dcdeadc8e958365251ba889a85 |
|
BLAKE2b-256 | bd6e314f890189d95826e62be32120012e1d0fe5709334efe133d0df2461cb38 |