报价用8片绒布。
flake8-quotes的Python项目详细描述
2.0.0中的主要更新
我们自动鼓励避免根据PEP 8转义引号。要禁用此选项,请使用--no-avoid-escape(可以通过avoid-escape在配置文件中使用)。
0.3.0中的折旧通知
为了预期多行支持,我们将--quotes重命名为--inline-quotes。请适当调整配置。
用法
如果您使用的是flake8,那么就很简单:
pip install flake8-quotes
现在你不必经常担心像@Section8这样的人了 抱怨你用的是双引号而不是单引号。
警告
此包添加前缀为Q0的flake8警告。你可能想 在flake8配置文件中启用此警告。一般来说 将是项目根文件夹中的.flake8。
select=Q0
当前的一组警告是:
Code | Description |
Q000 | Remove bad quotes |
Q001 | Remove bad quotes from multiline string |
Q002 | Remove bad quotes from docstring |
Q003 | Change outer quotes to avoid escaping inner quotes |
配置
默认情况下,我们希望使用单引号('),并查找不需要的双引号(“)。要使用双引号(“)并查找不需要的单引号('),请使用cli选项:
flake8 --inline-quotes '"'# We also support "double" and "single" # flake8 --inline-quotes 'double' # # We also support configuration for multiline quotes # flake8 --inline-quotes '"' --multiline-quotes "'" # We also support "'''" # flake8 --inline-quotes '"' --multiline-quotes "'''" # # We also support docstring quotes similarly # flake8 --inline-quotes '"' --docstring-quotes "'" # flake8 --inline-quotes '"' --docstring-quotes "'''" # We also support disabling escaping quotes # flake8 --no-avoid-escape
或tox.ini/setup.cfg中的配置选项。
inline-quotes="# We also support "double" and "single"# inline-quotes = double## We also support configuration for multiline quotes# multiline-quotes = '# We also support "'''"# multiline-quotes = '''## We also support docstring quotes similarly# docstring-quotes = '# docstring-quotes = '''## We also support disabling escaping quotes# avoid-escape = False
注意事项
我们遵循PEP8 conventions来避免字符串中的反斜杠。因此,无论您使用的是哪种配置(单引号或双引号),这些都是有效的字符串
s='double "quotes" wrapped in singles are ignored's="single 'quotes' wrapped in doubles are ignored"