进口订单编码标准 [英] Import order coding standard
本文介绍了进口订单编码标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PEP8 表明:
导入应按以下顺序分组:
Imports should be grouped in the following order:
- 标准库导入
- 相关的第三方进口
- 本地应用程序/库特定导入
您应该在每组导入之间放置一个空行.
You should put a blank line between each group of imports.
有没有办法使用静态代码分析工具检查包中的任何地方是否违反了标准,例如 pylint
、pyflakes
、pychecker
>, pep8
?
Is there a way to check if the standard is violated anywhere in the package using static code analysis tools, like pylint
, pyflakes
, pychecker
, 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.
The current version of pylint now does this, and reports it as error class C0411.
这篇关于进口订单编码标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文