[ruff] re and regex calls with unraw string as first argument (RUF039) (#14446)

This commit is contained in:
InSync 2024-11-19 19:44:55 +07:00 committed by GitHub
parent f8c20258ae
commit 5f09d4a90a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 832 additions and 0 deletions

View file

@ -0,0 +1,55 @@
import re
import regex
# Errors
re.compile('single free-spacing', flags=re.X)
re.findall('si\ngle')
re.finditer("dou\ble")
re.fullmatch('''t\riple single''')
re.match("""\triple double""")
re.search('two', 'args')
re.split("raw", r'second')
re.sub(u'''nicode''', u"f(?i)rst")
re.subn(b"""ytes are""", f"\u006e")
regex.compile('single free-spacing', flags=regex.X)
regex.findall('si\ngle')
regex.finditer("dou\ble")
regex.fullmatch('''t\riple single''')
regex.match("""\triple double""")
regex.search('two', 'args')
regex.split("raw", r'second')
regex.sub(u'''nicode''', u"f(?i)rst")
regex.subn(b"""ytes are""", f"\u006e")
regex.template("""(?m)
(?:ulti)?
(?=(?<!(?<=(?!l)))
l(?i:ne)
""", flags = regex.X)
# No errors
re.compile(R'uppercase')
re.findall(not_literal)
re.finditer(0, literal_but_not_string)
re.fullmatch() # no first argument
re.match('string' f'''concatenation''')
re.search(R"raw" r'concatenation')
re.split(rf"multiple", f"""lags""")
re.sub(FR'ee', '''as in free speech''')
re.subn(br"""eak your machine with rm -""", rf"""/""")
regex.compile(R'uppercase')
regex.findall(not_literal)
regex.finditer(0, literal_but_not_string)
regex.fullmatch() # no first argument
regex.match('string' f'''concatenation''')
regex.search(R"raw" r'concatenation')
regex.split(rf"multiple", f"""lags""")
regex.sub(FR'ee', '''as in free speech''')
regex.subn(br"""eak your machine with rm -""", rf"""/""")
regex.splititer(both, non_literal)
regex.subf(f, lambda _: r'means', '"format"')
regex.subfn(fn, f'''a$1n't''', lambda: "'function'")

View file

@ -0,0 +1,93 @@
import re
re.compile(
'implicit'
'concatenation'
)
re.findall(
r'''
multiline
'''
"""
concatenation
"""
)
re.finditer(
f'(?P<{group}>Dynamic'
r'\s+group'
'name)'
)
re.fullmatch(
u'n'r'''eadable'''
f'much?'
)
re.match(
b'reak'
br'eak'
)
re.search(
r''u''
'''okay?'''
)
re.split(''U"""w"""U'')
re.sub(
"I''m o"
'utta ideas'
)
re.subn("()"r' am I'"??")
import regex
regex.compile(
'implicit'
'concatenation'
)
regex.findall(
r'''
multiline
'''
"""
concatenation
"""
)
regex.finditer(
f'(?P<{group}>Dynamic'
r'\s+group'
'name)'
)
regex.fullmatch(
u'n'r'''eadable'''
f'much?'
)
regex.match(
b'reak'
br'eak'
)
regex.search(
r''u''
'''okay?'''
)
regex.split(''U"""w"""U'')
regex.sub(
"I''m o"
'utta ideas'
)
regex.subn("()"r' am I'"??")
regex.template(
r'''kitty says'''
r""r''r""r'aw'r""
)
regex.splititer(
r'r+r*r?'
)
regex.subf(
rb"haha"
br"ust go"
br''br""br''
)
regex.subfn(br'I\s\nee*d\s[O0o]me\x20\Qoffe\E, ' br'b')