markdown: Use immutable type for extension config.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-10-19 17:49:02 -07:00
parent 060036dfd5
commit 4398eecd2b
5 changed files with 9 additions and 9 deletions

View File

@@ -28,7 +28,7 @@ class MarkdownArgumentsTableGenerator(Extension):
class APIArgumentsTablePreprocessor(Preprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
self.base_path = config['base_path']

View File

@@ -22,7 +22,7 @@ class MarkdownReturnValuesTableGenerator(Extension):
class APIReturnValuesTablePreprocessor(Preprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
def run(self, lines: List[str]) -> List[str]:

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, List, Mapping, Optional, Tuple
from xml.etree.ElementTree import Element, SubElement
import markdown
@@ -16,7 +16,7 @@ class NestedCodeBlocksRenderer(Extension):
)
class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
def run(self, root: Element) -> None:

View File

@@ -1,5 +1,5 @@
import re
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Mapping, Optional
import markdown
from markdown.extensions import Extension
@@ -85,7 +85,7 @@ class TabbedSectionsGenerator(Extension):
)
class TabbedSectionsPreprocessor(Preprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
def run(self, lines: List[str]) -> List[str]:

View File

@@ -9,7 +9,7 @@ import inspect
import json
import re
import shlex
from typing import Any, Dict, List, Optional, Pattern, Tuple
from typing import Any, Dict, List, Mapping, Optional, Pattern, Tuple
import markdown
from django.conf import settings
@@ -358,7 +358,7 @@ class APIMarkdownExtension(Extension):
)
class APICodeExamplesPreprocessor(Preprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
self.api_url = config['api_url']
@@ -416,7 +416,7 @@ class APICodeExamplesPreprocessor(Preprocessor):
return fixture
class APIDescriptionPreprocessor(Preprocessor):
def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None:
def __init__(self, md: markdown.Markdown, config: Mapping[str, Any]) -> None:
super().__init__(md)
self.api_url = config['api_url']