@@ -56,8 +56,7 @@ def check_missing_backtick_after_role(file, lines, options=None):
5656 for paragraph_lno , paragraph in paragraphs (lines ):
5757 if paragraph .count ("|" ) > 4 :
5858 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 ):
6160 error_offset = paragraph [: error .start ()].count ("\n " )
6261 yield (
6362 paragraph_lno + error_offset ,
@@ -126,8 +125,7 @@ def check_default_role(file, lines, options=None):
126125 for lno , line in enumerate (lines , start = 1 ):
127126 line = clean_paragraph (line )
128127 line = escape2null (line )
129- match = rst .INTERPRETED_TEXT_RE .search (line )
130- if match :
128+ for match in rst .INTERPRETED_TEXT_RE .finditer (line ):
131129 before_match = line [: match .start ()]
132130 after_match = line [match .end () :]
133131 stripped_line = line .strip ()
@@ -201,8 +199,7 @@ def check_missing_space_after_role(file, lines, options=None):
201199 """
202200 for lno , line in enumerate (lines , start = 1 ):
203201 line = clean_paragraph (line )
204- role = _SUSPICIOUS_ROLE .search (line )
205- if role :
202+ for role in _SUSPICIOUS_ROLE .finditer (line ):
206203 yield lno , f"role missing (escaped) space after role: { role .group (0 )!r} "
207204
208205
@@ -214,8 +211,7 @@ def check_role_without_backticks(file, lines, options=None):
214211 Good: :func:`pdb.main`
215212 """
216213 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 ):
219215 yield lno , f"role with no backticks: { no_backticks .group (0 )!r} "
220216
221217
@@ -316,8 +312,7 @@ def check_missing_space_before_role(file, lines, options=None):
316312 if paragraph .count ("|" ) > 4 :
317313 return # we don't handle tables yet.
318314 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 ):
321316 error_offset = paragraph [: match .start ()].count ("\n " )
322317 if looks_like_glued (match ):
323318 yield (
@@ -386,8 +381,7 @@ def check_missing_colon_in_role(file, lines, options=None):
386381 Good: :issue:`123`
387382 """
388383 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 ):
391385 yield lno , f"role missing colon before first backtick ({ match .group (0 )} )."
392386
393387
@@ -471,8 +465,7 @@ def check_triple_backticks(file, lines, options=None):
471465 syntax, but it's really uncommon.
472466 """
473467 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 ):
476469 yield lno + 1 , "There's no rst syntax using triple backticks"
477470
478471
@@ -523,5 +516,5 @@ def check_unnecessary_parentheses(filename, lines, options):
523516 Good: :func:`test`
524517 """
525518 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 ):
527520 yield lno , f"Unnecessary parentheses in { match .group (0 ).strip ()!r} "
0 commit comments