@@ -56,8 +56,7 @@ def check_missing_backtick_after_role(file, lines, options=None):
56
56
for paragraph_lno , paragraph in paragraphs (lines ):
57
57
if paragraph .count ("|" ) > 4 :
58
58
return # we don't handle tables yet.
59
- error = rst .ROLE_MISSING_CLOSING_BACKTICK_RE .search (paragraph )
60
- if error :
59
+ for error in rst .ROLE_MISSING_CLOSING_BACKTICK_RE .finditer (paragraph ):
61
60
error_offset = paragraph [: error .start ()].count ("\n " )
62
61
yield (
63
62
paragraph_lno + error_offset ,
@@ -126,8 +125,7 @@ def check_default_role(file, lines, options=None):
126
125
for lno , line in enumerate (lines , start = 1 ):
127
126
line = clean_paragraph (line )
128
127
line = escape2null (line )
129
- match = rst .INTERPRETED_TEXT_RE .search (line )
130
- if match :
128
+ for match in rst .INTERPRETED_TEXT_RE .finditer (line ):
131
129
before_match = line [: match .start ()]
132
130
after_match = line [match .end () :]
133
131
stripped_line = line .strip ()
@@ -201,8 +199,7 @@ def check_missing_space_after_role(file, lines, options=None):
201
199
"""
202
200
for lno , line in enumerate (lines , start = 1 ):
203
201
line = clean_paragraph (line )
204
- role = _SUSPICIOUS_ROLE .search (line )
205
- if role :
202
+ for role in _SUSPICIOUS_ROLE .finditer (line ):
206
203
yield lno , f"role missing (escaped) space after role: { role .group (0 )!r} "
207
204
208
205
@@ -214,8 +211,7 @@ def check_role_without_backticks(file, lines, options=None):
214
211
Good: :func:`pdb.main`
215
212
"""
216
213
for lno , line in enumerate (lines , start = 1 ):
217
- no_backticks = rst .ROLE_WITH_NO_BACKTICKS_RE .search (line )
218
- if no_backticks :
214
+ for no_backticks in rst .ROLE_WITH_NO_BACKTICKS_RE .finditer (line ):
219
215
yield lno , f"role with no backticks: { no_backticks .group (0 )!r} "
220
216
221
217
@@ -316,8 +312,7 @@ def check_missing_space_before_role(file, lines, options=None):
316
312
if paragraph .count ("|" ) > 4 :
317
313
return # we don't handle tables yet.
318
314
paragraph = clean_paragraph (paragraph )
319
- match = rst .ROLE_GLUED_WITH_WORD_RE .search (paragraph )
320
- if match :
315
+ for match in rst .ROLE_GLUED_WITH_WORD_RE .finditer (paragraph ):
321
316
error_offset = paragraph [: match .start ()].count ("\n " )
322
317
if looks_like_glued (match ):
323
318
yield (
@@ -386,8 +381,7 @@ def check_missing_colon_in_role(file, lines, options=None):
386
381
Good: :issue:`123`
387
382
"""
388
383
for lno , line in enumerate (lines , start = 1 ):
389
- match = rst .ROLE_MISSING_RIGHT_COLON_RE .search (line )
390
- if match :
384
+ for match in rst .ROLE_MISSING_RIGHT_COLON_RE .finditer (line ):
391
385
yield lno , f"role missing colon before first backtick ({ match .group (0 )} )."
392
386
393
387
@@ -471,8 +465,7 @@ def check_triple_backticks(file, lines, options=None):
471
465
syntax, but it's really uncommon.
472
466
"""
473
467
for lno , line in enumerate (lines ):
474
- match = rst .TRIPLE_BACKTICKS_RE .search (line )
475
- if match :
468
+ for match in rst .TRIPLE_BACKTICKS_RE .finditer (line ):
476
469
yield lno + 1 , "There's no rst syntax using triple backticks"
477
470
478
471
@@ -523,5 +516,5 @@ def check_unnecessary_parentheses(filename, lines, options):
523
516
Good: :func:`test`
524
517
"""
525
518
for lno , line in enumerate (lines , start = 1 ):
526
- if match := rst .ROLE_WITH_UNNECESSARY_PARENTHESES_RE .search (line ):
519
+ for match in rst .ROLE_WITH_UNNECESSARY_PARENTHESES_RE .finditer (line ):
527
520
yield lno , f"Unnecessary parentheses in { match .group (0 ).strip ()!r} "
0 commit comments