当前位置:网站首页>Sourcery插件(自动提升代码质量)
Sourcery插件(自动提升代码质量)
2022-07-31 05:16:00 【王大队长】
目录
Sourcery的功能如标题所说,能够自动提升代码质量,话不多说,直接上例子:
示例:
我在pycharm中已经安装好了此插件,下面写一个函数将输入x夹断到0~100:
def clip(x):
if x > 100:
x = 100
if x < 0:
x = 0
可以看到此插件给了我一个提示(黄色波浪线),可以将代码优化为绿色代码:
我们只需在黄色波浪线后面按Alt + Enter就能实现自动替换:
def clip(x):
x = min(x, 100)
x = max(x, 0)
可以看到还是非常强大的!但是也有些许不足(毕竟是Ai修改,还不能达到特别理想的效果),比如我们将上面的if x < 0: 改成elif x < 0: 插件便检测不出来了(可以看到黄色下划线消失了)!
Sourcery官方链接:
Sourcery | Automatically Improve Python Code Quality
安装步骤(pyCharm):
这里我选择用goole账号登录(这里如果一直加载不进去就用迅雷进去):
复制你的token :
打开pycharm安装插件,安装后重启pyCharm:
将token复制进去,:
然后点击apply再点ok即可!
Sourcery支持的IDE:
边栏推荐
- 使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)
- [swagger close] The production environment closes the swagger method
- 360 hardening file path not exists.
- jenkins +miniprogram-ci 一键上传微信小程序
- cocoscreator3.5.2打包微信小游戏发布到QQ小游戏修改
- ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
- UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
- VS通过ODBC连接MYSQL(二)
- VTK环境配置
- flutter arr 依赖
猜你喜欢
Notes on creating a new virtual machine in Hyper-V
[swagger close] The production environment closes the swagger method
Gradle sync failed: Uninitialized object exists on backward branch 142
QT VS中双击ui文件无法打开的问题
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
Access database query
Artifact SSMwar exploded Error deploying artifact.See server log for details
Nmap的下载与安装
WeChat applet source code acquisition and decompilation method
Using IIS10 to build an asp website in win11
随机推荐
2021年京东数据分析工程师秋招笔试编程题
Several solutions for mysql startup error The server quit without updating PID file
SSH automatic reconnection script
JS写一段代码,判断一个字符串中出现次数最多的字符串,并统计出现的次数JS
understand js operators
cv2.imread()
js中的全局作用域与函数作用域
[swagger close] The production environment closes the swagger method
网页截图与反向代理
Common JVM interview questions and answers
powershell统计文件夹大小
Chinese garbled solution in UTF-8 environment in Powershell
VTK环境配置
Nmap的下载与安装
quick-3.5 ActionTimeline的setLastFrameCallFunc调用会崩溃问题
Global scope and function scope in js
After unicloud is released, the applet prompts that the connection to the local debugging service failed. Please check whether the client and the host are under the same local area network.
js中的this指向与原型对象
cocos2d-x-3.2创建项目方法
flutter arr dependencies