mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Make zerver/lib/bugdown/fenced_code.py pass mypy check.
This commit is contained in:
		@@ -17,7 +17,6 @@ bots/zephyr_mirror_backend.py
 | 
			
		||||
docs/conf.py
 | 
			
		||||
tools/deprecated/
 | 
			
		||||
zproject/
 | 
			
		||||
zerver/lib/bugdown/fenced_code.py
 | 
			
		||||
zerver/lib/statistics.py
 | 
			
		||||
zerver/middleware.py
 | 
			
		||||
zerver/migrations/
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,7 @@ Dependencies:
 | 
			
		||||
import re
 | 
			
		||||
import markdown
 | 
			
		||||
from zerver.lib.bugdown.codehilite import CodeHilite, CodeHiliteExtension
 | 
			
		||||
from typing import Dict, List, Sequence
 | 
			
		||||
 | 
			
		||||
# Global vars
 | 
			
		||||
FENCE_RE = re.compile(r"""
 | 
			
		||||
@@ -114,12 +115,12 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
 | 
			
		||||
        markdown.preprocessors.Preprocessor.__init__(self, md)
 | 
			
		||||
 | 
			
		||||
        self.checked_for_codehilite = False
 | 
			
		||||
        self.codehilite_conf = {}
 | 
			
		||||
        self.codehilite_conf = {} # type: Dict[str, Dict[int, str]]
 | 
			
		||||
 | 
			
		||||
    def run(self, lines):
 | 
			
		||||
        """ Match and store Fenced Code Blocks in the HtmlStash. """
 | 
			
		||||
 | 
			
		||||
        output = []
 | 
			
		||||
        output = [] # type: List[str]
 | 
			
		||||
 | 
			
		||||
        class Record(object):
 | 
			
		||||
            pass
 | 
			
		||||
@@ -133,16 +134,6 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
 | 
			
		||||
        def pop():
 | 
			
		||||
            handlers.pop()
 | 
			
		||||
 | 
			
		||||
        class OuterHandler(object):
 | 
			
		||||
            def __init__(self, output):
 | 
			
		||||
                self.output = output
 | 
			
		||||
 | 
			
		||||
            def handle_line(self, line):
 | 
			
		||||
                check_for_new_fence(self.output, line)
 | 
			
		||||
 | 
			
		||||
            def done(self):
 | 
			
		||||
                pop()
 | 
			
		||||
 | 
			
		||||
        def check_for_new_fence(output, line):
 | 
			
		||||
            m = FENCE_RE.match(line)
 | 
			
		||||
            if m:
 | 
			
		||||
@@ -153,6 +144,16 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
 | 
			
		||||
            else:
 | 
			
		||||
                output.append(line)
 | 
			
		||||
 | 
			
		||||
        class OuterHandler(object):
 | 
			
		||||
            def __init__(self, output):
 | 
			
		||||
                self.output = output
 | 
			
		||||
 | 
			
		||||
            def handle_line(self, line):
 | 
			
		||||
                check_for_new_fence(self.output, line)
 | 
			
		||||
 | 
			
		||||
            def done(self):
 | 
			
		||||
                pop()
 | 
			
		||||
 | 
			
		||||
        def generic_handler(output, fence, lang):
 | 
			
		||||
            if lang in ('quote', 'quoted'):
 | 
			
		||||
                return QuoteHandler(output, fence)
 | 
			
		||||
@@ -163,7 +164,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
 | 
			
		||||
            def __init__(self, output, fence):
 | 
			
		||||
                self.output = output
 | 
			
		||||
                self.fence = fence
 | 
			
		||||
                self.lines = []
 | 
			
		||||
                self.lines = [] # type: Sequence[str]
 | 
			
		||||
 | 
			
		||||
            def handle_line(self, line):
 | 
			
		||||
                if line.rstrip() == self.fence:
 | 
			
		||||
@@ -185,7 +186,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
 | 
			
		||||
                self.output = output
 | 
			
		||||
                self.fence = fence
 | 
			
		||||
                self.lang = lang
 | 
			
		||||
                self.lines = []
 | 
			
		||||
                self.lines = [] # type: Sequence[str]
 | 
			
		||||
 | 
			
		||||
            def handle_line(self, line):
 | 
			
		||||
                if line.rstrip() == self.fence:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user