@@ -171,14 +171,14 @@ def __init__(self, *args):
171171 super ().__init__ (* args )
172172 self .INDENT_RE = re .compile (r'^(([ ]{%s})+)' % self .tab_length )
173173
174- def test (self , parent , block ) :
174+ def test (self , parent : etree . Element , block : str ) -> bool :
175175 return block .startswith (' ' * self .tab_length ) and \
176176 not self .parser .state .isstate ('detabbed' ) and \
177177 (parent .tag in self .ITEM_TYPES or
178178 (len (parent ) and parent [- 1 ] is not None and
179179 (parent [- 1 ].tag in self .LIST_TYPES )))
180180
181- def run (self , parent , blocks ) :
181+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
182182 block = blocks .pop (0 )
183183 level , sibling = self .get_level (parent , block )
184184 block = self .looseDetab (block , level )
@@ -251,10 +251,10 @@ def get_level(self, parent: etree.Element, block: str) -> tuple[int, etree.Eleme
251251class CodeBlockProcessor (BlockProcessor ):
252252 """ Process code blocks. """
253253
254- def test (self , parent , block ) :
254+ def test (self , parent : etree . Element , block : str ) -> bool :
255255 return block .startswith (' ' * self .tab_length )
256256
257- def run (self , parent , blocks ) :
257+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
258258 sibling = self .lastChild (parent )
259259 block = blocks .pop (0 )
260260 theRest = ''
@@ -286,10 +286,10 @@ class BlockQuoteProcessor(BlockProcessor):
286286
287287 RE = re .compile (r'(^|\n)[ ]{0,3}>[ ]?(.*)' )
288288
289- def test (self , parent , block ) :
289+ def test (self , parent : etree . Element , block : str ) -> bool :
290290 return bool (self .RE .search (block )) and not util .nearing_recursion_limit ()
291291
292- def run (self , parent , blocks ) :
292+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
293293 block = blocks .pop (0 )
294294 m = self .RE .search (block )
295295 if m :
@@ -353,10 +353,10 @@ def __init__(self, parser: BlockParser):
353353 self .INDENT_RE = re .compile (r'^[ ]{%d,%d}((\d+\.)|[*+-])[ ]+.*' %
354354 (self .tab_length , self .tab_length * 2 - 1 ))
355355
356- def test (self , parent , block ) :
356+ def test (self , parent : etree . Element , block : str ) -> bool :
357357 return bool (self .RE .match (block ))
358358
359- def run (self , parent , blocks ) :
359+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
360360 # Check for multiple items in one block.
361361 items = self .get_items (blocks .pop (0 ))
362362 sibling = self .lastChild (parent )
@@ -460,10 +460,10 @@ class HashHeaderProcessor(BlockProcessor):
460460 # Detect a header at start of any line in block
461461 RE = re .compile (r'(?:^|\n)(?P<level>#{1,6})(?P<header>(?:\\.|[^\\])*?)#*(?:\n|$)' )
462462
463- def test (self , parent , block ) :
463+ def test (self , parent : etree . Element , block : str ) -> bool :
464464 return bool (self .RE .search (block ))
465465
466- def run (self , parent , blocks ) :
466+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
467467 block = blocks .pop (0 )
468468 m = self .RE .search (block )
469469 if m :
@@ -491,10 +491,10 @@ class SetextHeaderProcessor(BlockProcessor):
491491 # Detect Setext-style header. Must be first 2 lines of block.
492492 RE = re .compile (r'^.*?\n[=-]+[ ]*(\n|$)' , re .MULTILINE )
493493
494- def test (self , parent , block ) :
494+ def test (self , parent : etree . Element , block : str ) -> bool :
495495 return bool (self .RE .match (block ))
496496
497- def run (self , parent , blocks ) :
497+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
498498 lines = blocks .pop (0 ).split ('\n ' )
499499 # Determine level. `=` is 1 and `-` is 2.
500500 if lines [1 ].startswith ('=' ):
@@ -517,15 +517,15 @@ class HRProcessor(BlockProcessor):
517517 # Detect hr on any line of a block.
518518 SEARCH_RE = re .compile (RE , re .MULTILINE )
519519
520- def test (self , parent , block ) :
520+ def test (self , parent : etree . Element , block : str ) -> bool :
521521 m = self .SEARCH_RE .search (block )
522522 if m :
523523 # Save match object on class instance so we can use it later.
524524 self .match = m
525525 return True
526526 return False
527527
528- def run (self , parent , blocks ) :
528+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
529529 block = blocks .pop (0 )
530530 match = self .match
531531 # Check for lines in block before `hr`.
@@ -545,10 +545,10 @@ def run(self, parent, blocks):
545545class EmptyBlockProcessor (BlockProcessor ):
546546 """ Process blocks that are empty or start with an empty line. """
547547
548- def test (self , parent , block ) :
548+ def test (self , parent : etree . Element , block : str ) -> bool :
549549 return not block or block .startswith ('\n ' )
550550
551- def run (self , parent , blocks ) :
551+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
552552 block = blocks .pop (0 )
553553 filler = '\n \n '
554554 if block :
@@ -575,10 +575,10 @@ class ReferenceProcessor(BlockProcessor):
575575 r'^[ ]{0,3}\[([^\[\]]*)\]:[ ]*\n?[ ]*([^\s]+)[ ]*(?:\n[ ]*)?((["\'])(.*)\4[ ]*|\((.*)\)[ ]*)?$' , re .MULTILINE
576576 )
577577
578- def test (self , parent , block ) :
578+ def test (self , parent : etree . Element , block : str ) -> bool :
579579 return True
580580
581- def run (self , parent , blocks ) :
581+ def run (self , parent : etree . Element , blocks : list [ str ]) -> bool :
582582 block = blocks .pop (0 )
583583 m = self .RE .search (block )
584584 if m :
@@ -601,10 +601,10 @@ def run(self, parent, blocks):
601601class ParagraphProcessor (BlockProcessor ):
602602 """ Process Paragraph blocks. """
603603
604- def test (self , parent , block ) :
604+ def test (self , parent : etree . Element , block : str ) -> bool :
605605 return True
606606
607- def run (self , parent , blocks ) :
607+ def run (self , parent : etree . Element , blocks : list [ str ]) -> None :
608608 block = blocks .pop (0 )
609609 if block .strip ():
610610 # Not a blank block. Add to parent, otherwise throw it away.
0 commit comments