Colderleo's blog Colderleo's blog
首页
Linux
C++
Python
前端
工具软件
mysql
索引
关于
GitHub (opens new window)

Colder Leo

热爱代码的打工人
首页
Linux
C++
Python
前端
工具软件
mysql
索引
关于
GitHub (opens new window)
  • 1-django使用
  • centos部署Nginx+uwsgi+django - blog
  • django-admin完全自定义某个模块的页面
  • easy_select2 编辑页面添加外键选择搜索
  • 使用vscode开发python
    • 使用vscode配置python开发环境
    • 配置pylint
  • python自定义异常处理with,上下文context管理器
  • python读写excel,xlsx 模块选择
  • python多线程多进程协程
  • TemporaryFile
  • threading用法
  • ubantu设置python优先级
  • conda anacodna 命令行用法
  • 我写的常用工具函数
  • 0-python常用函数
  • smtp发送邮件
  • pandas用法
  • datetime类,时间差
  • format
  • enumerate遍历数组时获取index
  • argv
  • generator 生成器
  • GIL锁、多线程
  • linux用源文件安装python3
  • list sort排序
  • logging日志
  • mulitporcessing共享变量
  • OrderedDict
  • path
  • pip用法
  • pymysql用法 - python连接mysql
  • python bash解释器,脚本前两行,
  • python docstring格式 PEP 257
  • python logging获取logger信息
  • python交互式窗口如何进行多行输入
  • virtualenv用法
  • 标准差
  • 单例模式
  • 函数中定义static变量
  • 切片
  • 去掉字符串中emoji字符
  • 去掉字符串中的空行
  • 全局变量、global和nonlocal
  • 文字识别pytesseract
  • 析构函数和del
  • 用python制作游戏外挂
  • 正则表达式,函数替换字符串
  • 装饰器
  • pycharm中运行pyqt时不报错
  • python 写文件
  • Python
gaoliu
2021-10-06
目录
使用vscode配置python开发环境
配置pylint

使用vscode开发python

# 使用vscode配置python开发环境

https://www.cnblogs.com/shine-lee/p/10234378.html

# 配置code-runner的python环境

https://blog.csdn.net/lojloj/article/details/102849195 安装插件code-runner, 配置python虚拟环境:

# 配置pylint

# 在行级别或者文件级别配置pylint

https://blog.csdn.net/u013687821/article/details/51127070

行级别 (W0102:dangerous-default-value)

def file_travesal(dirtectory='.', file_list=[]): # pylint: disable=W0102
    '''
    Get file list from the directory including files in its subdirectories.
    '''
    file_list += [join(dirtectory, f) for f in listdir(dirtectory)
                if isfile(join(dirtectory, f))]
    for item in listdir(dirtectory):
        if isdir(join(dirtectory, item)):
            file_travesal(join(dirtectory, item), file_list)
            
1
2
3
4
5
6
7
8
9
10

文件级别,在文件开始的地方加入下面的注释

#! usr/bin/python
# pylint: disable=used-before-assignment
# pylint: disable=no-member

 
''' Docstring... '''

1
2
3
4
5
6
7

# pylint中 import pyqt时有错误提示

https://blog.csdn.net/ouening/article/details/81805771

VS Code Pylint出现E0611:No name 'Qt' in module 'PyQt5.QtCore'解决办法

软件平台:VS Code,pylint 在VS 中使用pylint,编辑pyqt5文件时出现了很多代码错误提示,通过网上查找资料得到下面解决方法:

原因:新版pylint默认不支持外部扩展模块,(出于安全性考虑) pyqt5是C++写的外部扩展,因此在【用户设置】那里把pyqt加入pylint的白名单:

"python.linting.pylintArgs": [
        "--extension-pkg-whitelist=PyQt5"
    ]
1
2
3

pylint doesn't load any C extensions by default, because those can run arbitrary code. Since you probably trust PyQt, run pylint with --extension-pkg-whitelist=PyQt

# vscode中配置pylint disable一些规则

前两行是vscode自身的配置,跟pylint无关

{
    "workbench.colorTheme": "Quiet Light",
    "window.zoomLevel": 1,
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=PyQt5",
        "--disable=C0326",
        "--disable=multiple-imports",
        "--disable=superfluous-parens",
        "--disable=missing-function-docstring",
        "--disable=wrong-import-order",
        "--disable=missing-module-docstring",
        "--disable=trailing-whitespace",
        "--disable=line-too-long",
        "--disable=logging-not-lazy",
        "--disable=missing-class-docstring",
        "--disable=bare-except",
        "--disable=trailing-newlines",
        "--disable=broad-except",
        "--disable=no-member",
        "--disable=attribute-defined-outside-init",
        "--disable=arguments-differ",
        "--disable=access-member-before-definition",
        "--disable=logging-format-interpolation",
        "--disable=generated-members",
        "--good-names=a,b,c,d,i,j,k,wi,GlobalData,id,DB"
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

如果使用django,可以这样: https://www.cnblogs.com/chaojihexiang/p/6417835.html (opens new window)

//安装pylint-django
pip install pylint-django

//配置vscode的settings
{
    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint_django"
    ]
}
1
2
3
4
5
6
7
8
9
10

也可以按照提示级别进行屏蔽:

https://jingyan.baidu.com/article/fdbd4277b0241fb89e3f482b.html

disable=C,R,W

C, vonvention, 惯例
R, refactor, 重构
W, warning
E, error
F, fatal
1
2
3
4
5
6
7

# unused variable 如果是占位需要可以使用下划线

https://blog.csdn.net/yyt_1995/article/details/92992500

W0612(unused-variable)定义了变量却没有使用 如果是需要占位,则使用下划线开头

# pylint详细配置规则

https://github.com/robot527/python_primer/blob/master/pylint.conf

这里面讲了更详细的配置规则,不仅仅是disable掉某条规则。如果在vscode中使用该配置,需要在前面加上--, 如--disable, --good-names

# pylint完整的规则列表

官网:https://www.pylint.org/

官网里面有完整的规则列表:the complete check list,可以查看你需要disable的规则代码。 https://pylint.readthedocs.io/en/latest/technical_reference/features.html

编辑 (opens new window)
上次更新: 2021/11/23, 14:25:33
easy_select2 编辑页面添加外键选择搜索
python自定义异常处理with,上下文context管理器

← easy_select2 编辑页面添加外键选择搜索 python自定义异常处理with,上下文context管理器→

最近更新
01
通过模板实现结构体成员拷贝-按成员名匹配
05-07
02
c++17通过模板获取类成员的个数
05-01
03
avx-sse切换惩罚
04-30
更多文章>

Related Issues not found

Please contact @colderleo to initialize the comment

Theme by Vdoing | Copyright © 2019-2025 Colder Leo | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×