Force string format in pylint

烈酒焚心 提交于 2019-12-08 16:31:52

问题


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

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


回答1:


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

You can get it with

pip install pylint-quotes

Then to use it with pylint,

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

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



回答2:


I don't think pylint can currently do this, but there's a extension for flake8 called flake8-quotes.



来源:https://stackoverflow.com/questions/36490128/force-string-format-in-pylint

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!