@@ -64,6 +64,7 @@ def check_missing_backtick_after_role(file, lines, options=None):
6464
6565
6666_RST_ROLE_RE = re .compile ("``.+?``(?!`)." , flags = re .DOTALL )
67+ _END_STRING_SUFFIX_RE = re .compile (rst .END_STRING_SUFFIX )
6768
6869
6970@checker (".rst" , ".po" )
@@ -78,7 +79,7 @@ def check_missing_space_after_literal(file, lines, options=None):
7879 return # we don't handle tables yet.
7980 paragraph = clean_paragraph (paragraph )
8081 for role in _RST_ROLE_RE .finditer (paragraph ):
81- if not rst . END_STRING_SUFFIX_RE .match (role [0 ][- 1 ]):
82+ if not _END_STRING_SUFFIX_RE .match (role [0 ][- 1 ]):
8283 error_offset = paragraph [: role .start ()].count ("\n " )
8384 yield (
8485 paragraph_lno + error_offset ,
@@ -405,8 +406,8 @@ def check_missing_final_newline(file, lines, options=None):
405406
406407
407408_is_long_interpreted_text = re .compile (r"^\s*\W*(:(\w+:)+)?`.*`\W*$" ).match
408- _is_directive_or_hyperlink = re .compile (r"^\s*\.\. " ).match
409- _is_anonymous_hyperlink = re .compile (r"^\s*__ " ).match
409+ _starts_with_directive_or_hyperlink = re .compile (r"^\s*\.\. " ).match
410+ _starts_with_anonymous_hyperlink = re .compile (r"^\s*__ " ).match
410411_is_very_long_string_literal = re .compile (r"^\s*``[^`]+``$" ).match
411412
412413
@@ -420,9 +421,9 @@ def check_line_too_long(file, lines, options=None):
420421 continue # ignore wide tables
421422 if _is_long_interpreted_text (line ):
422423 continue # ignore long interpreted text
423- if _is_directive_or_hyperlink (line ):
424+ if _starts_with_directive_or_hyperlink (line ):
424425 continue # ignore directives and hyperlink targets
425- if _is_anonymous_hyperlink (line ):
426+ if _starts_with_anonymous_hyperlink (line ):
426427 continue # ignore anonymous hyperlink targets
427428 if _is_very_long_string_literal (line ):
428429 continue # ignore a very long literal string
@@ -457,7 +458,7 @@ def check_triple_backticks(file, lines, options=None):
457458 yield lno + 1 , "There's no rst syntax using triple backticks"
458459
459460
460- _contains_bad_dedent = re .compile (" [^ ].*::$" ).match
461+ _has_bad_dedent = re .compile (" [^ ].*::$" ).match
461462
462463
463464@checker (".rst" , ".po" , rst_only = False )
@@ -477,20 +478,20 @@ def check_bad_dedent(file, lines, options=None):
477478
478479 def check_block (block_lineno , block ):
479480 for lineno , line in enumerate (block .splitlines ()):
480- if _contains_bad_dedent (line ):
481+ if _has_bad_dedent (line ):
481482 errors .append ((block_lineno + lineno , "Bad dedent in block" ))
482483
483484 list (hide_non_rst_blocks (lines , hidden_block_cb = check_block ))
484485 yield from errors
485486
486487
487- _contains_dangling_hyphen = re .compile (r".*[a-z]-$" ).match
488+ _has_dangling_hyphen = re .compile (r".*[a-z]-$" ).match
488489
489490
490491@checker (".rst" , rst_only = True )
491492def check_dangling_hyphen (file , lines , options ):
492493 """Check for lines ending in a hyphen."""
493494 for lno , line in enumerate (lines ):
494495 stripped_line = line .rstrip ("\n " )
495- if _contains_dangling_hyphen (stripped_line ):
496+ if _has_dangling_hyphen (stripped_line ):
496497 yield lno + 1 , f"Line ends with dangling hyphen"
0 commit comments