Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

markdown: Use immutable type for extension config.

Anders Kaseorg4398eecd2b85
diff --git a/zerver/lib/markdown/api_arguments_table_generator.py b/zerver/lib/markdown/api_arguments_table_generator.py
index 70c43f5cd00..80126feb1a9 100644
--- a/zerver/lib/markdown/api_arguments_table_generator.py
+++ b/zerver/lib/markdown/api_arguments_table_generator.py
@@ -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']
diff --git a/zerver/lib/markdown/api_return_values_table_generator.py b/zerver/lib/markdown/api_return_values_table_generator.py
index 6f9dc6393f7..b0e7f08b0cc 100644
--- a/zerver/lib/markdown/api_return_values_table_generator.py
+++ b/zerver/lib/markdown/api_return_values_table_generator.py
@@ -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]:
diff --git a/zerver/lib/markdown/nested_code_blocks.py b/zerver/lib/markdown/nested_code_blocks.py
index 40f417a82e4..b64337e1cce 100644
--- a/zerver/lib/markdown/nested_code_blocks.py
+++ b/zerver/lib/markdown/nested_code_blocks.py
@@ -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:
diff --git a/zerver/lib/markdown/tabbed_sections.py b/zerver/lib/markdown/tabbed_sections.py
index 6eb918aea95..a5952af030b 100644
--- a/zerver/lib/markdown/tabbed_sections.py
+++ b/zerver/lib/markdown/tabbed_sections.py
@@ -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]:
diff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.py
index 52322e630f4..f9a60dcd36f 100644
--- a/zerver/openapi/markdown_extension.py
+++ b/zerver/openapi/markdown_extension.py
@@ -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']