python - 进口订单编码标准

标签 python python-import static-analysis pep8

PEP8建议:

Imports should be grouped in the following order:

  1. standard library imports
  2. related third party imports
  3. local application/library specific imports

You should put a blank line between each group of imports.

有没有办法使用静态代码分析工具检查包中的任何地方是否违反标准,例如 pylintpyflakespychecker, pep8?


违规示例:

from my_package import my_module
from django.db import models
import os

正确的导入方式:

import os

from django.db import models

from my_package import my_module

最佳答案

当前版本的 pylint 现在执行此操作,并将其报告为错误类 C0411。

关于python - 进口订单编码标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22722976/

相关文章:

python - 执行 pandas.merge() 时系统卡住

python:不同包下同名的两个模块和类

python - 无法在 Linux 上导入 Python 包

python - 如何增量训练 H2O 朴素贝叶斯分类器?

python - 如何在 python 中的匹配行之后获取行

python - 面对python继承中的问题

c++ - CLion(和其他 IDE?)的 "#pragma ide diagnostic ignored"列表

xcode - OCLint 生成空的compile_commands.json

python - 为什么 mypy 在 MonkeyType 自动注释的模块上失败?

python - 在 Python 中检查字符串的 Python 语法?