当前位置:网站首页>code inspection tool
code inspection tool
2022-08-08 09:31:00 【User 9127725】
Python is good everywhere, but too much indentation and too much nesting can easily cause syntax errors that are difficult to check, so we need a static checking software
Here introduces a static check tool: flake8.
Introduction to flake8
It is a wrapper for the following three tools:
PyFlakes: python source code check: redundant import; duplicate function definition; variable name conflict...
Pep8: Code Style Check
Ned Batchelder's McCabe script: Code Complexity Check
Three functions:
Python code style check, so that the project meets a good code style, and it is easy to find problems.
Some basic code checks.
git integration
flake8 use
Install: pip install flake8
Check: flake8 [python source directory or file]
Ignore rule contact, there are two main ways:
Ignore the static check of the entire file, add a comment: # flake8: noqa
Ignore certain errors, you can modify setup.cfg (eg ignore E265 rules):
[flake8]
ignore = E265
git integration: The flake8 check is automatically done before git commits, and the commit can only be done after the check is successful. Under the local git branch, perform the following two steps:
- flake8 --install-hook
- git config flake8.strict true
The principle of flake8 git integration: bury git hooks. (.git/hooks/pre-commit)
Other tools
pylint: The rules are relatively dead, and a lot of errors will be produced. It is difficult to ensure that there are no errors. It is not suitable for our project.
pycharm: comes with pep8, pyflake check, and can also integrate flake8. Recommended editor
Radon: Complexity Check.
边栏推荐
- COMSOL Multiphysics 6.0软件安装包和安装教程
- Offensive and defensive world - fakebook
- 写在 26 岁生日
- 文献学习(part33)--Clustering by fast search and find of density peaks
- 入职半个月的一些思考
- Pinia(一)初体验快速安装与上手
- 干货 | Oracle数据库操作命令大全,满满的案例供你理解,收藏!
- Stanford Fall 21: Practical Machine Learning [Chapter 5]
- 移动端/嵌入式-CV模型-2018:MobelNets-v2
- Use of .json()
猜你喜欢
Multi-scalar multiplication: state of the art & new ideas
LAN技术-5Eth-Trunk
SSRF漏洞
攻防世界——ics-05
Excel中text函数5中常用方法
Pinia(一)初体验快速安装与上手
2022 - image classification 】 【 MaxViT ECCV
COMSOL Multiphysics 6.0 software installation package and installation tutorial
【office】word
Bytes and Characters and Common Encodings
随机推荐
FRED应用:TMT MOBIE成像光谱仪的概念设计阶段杂散光分析
LabVIEW前面板和程序框图的最大尺寸
等式变换(2015届华为校园招聘机试题第三题 )
移动端/嵌入式-CV模型-2018:MobileFaceNets
Recommend 100 nice English songs
HyperLynx(三)传输线类型及相关设置
LVS负载均衡群集及NAT模式群集
Debug 调式程序
继承关系下构造方法的访问特点:
渗透测试-xss的三种类型讲解
PHP 手机号脱敏,正则表达式/简易版
Go 函数与方法
【Collection】3. Wallpaper collection
正确使用灯光 安全文明出行
nodeJs--egg框架介绍
Excel中text函数5中常用方法
【图像分类】2021-CoAtNet NeurlPS
xgboost 加速
数据库调优:Mysql索引对group by 排序的影响
移动端/嵌入式-CV模型-2018:MobelNets-v2