在pylint中强制使用字符串格式 [英] Force string format in pylint

查看:41
本文介绍了在pylint中强制使用字符串格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 允许对字符串使用单引号或双引号.我想在我的项目中只强制使用单引号格式.

Python allows to use either single or double quotes for strings. I'd like to enforce only single quotes format in my projects.

pylint 或现有的 pylint 插件中是否有任何特定规则来实现这一点?

Is there any specific rule in pylint or an existing pylint plugin to achieve that?

推荐答案

我最近为此编写了一个 pylint 插件:https://pypi.python.org/pypi/pylint-quotes

I recently wrote a pylint plugin for this: https://pypi.python.org/pypi/pylint-quotes

你可以用

pip install pylint-quotes

然后与pylint一起使用,

Then to use it with pylint,

pylint --load-plugins pylint_quotes <module-or-package>

.pylintrc 文件中,您可以配置要使用的引号:

in the .pylintrc file, you can configure which quotes to use:

# Set the linting for string quotes
string-quote=single
triple-quote=double
docstring-quote=double

这篇关于在pylint中强制使用字符串格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆