unraw-re-pattern (RUF039)
有时提供修复。
此规则不稳定且处于预览状态。使用需要 --preview
标志。
作用
当 re
和 regex
调用的第一个参数不是原始字符串时,报告以下情况
- 对于
regex
和re
:compile
、findall
、finditer
、fullmatch
、match
、search
、split
、sub
、subn
。 regex
特有:splititer
、subf
、subfn
、template
。
为什么这不好?
正则表达式应该使用原始字符串编写,以避免双重转义。
示例
建议改为