Skip to content

Commit 2eccc3d

Browse files
committed
Loosen up config typing
1 parent f738760 commit 2eccc3d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

markdown_it/main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from contextlib import contextmanager
2-
from typing import Any, Callable, Dict, List, Optional, Union
2+
from typing import Any, Callable, Dict, List, Mapping, Optional, Union
33

44
from . import helpers, presets # noqa F401
55
from .common import utils # noqa F401
@@ -23,7 +23,7 @@
2323

2424
class MarkdownIt:
2525
def __init__(
26-
self, config: Union[str, AttrDict] = "commonmark", renderer_cls=RendererHTML
26+
self, config: Union[str, Mapping] = "commonmark", renderer_cls=RendererHTML
2727
):
2828
"""Main parser class
2929
@@ -65,7 +65,7 @@ def set(self, options):
6565
"""
6666
self.options = options
6767

68-
def configure(self, presets: Union[str, AttrDict]):
68+
def configure(self, presets: Union[str, Mapping]):
6969
"""Batch load of all options and component settings.
7070
This is an internal method, and you probably will not need it.
7171
But if you will - see available presets and data structure
@@ -83,13 +83,13 @@ def configure(self, presets: Union[str, AttrDict]):
8383
)
8484
if not presets:
8585
raise ValueError("Wrong `markdown-it` preset, can't be empty")
86-
presets = AttrDict(presets)
86+
attr_presets = AttrDict(presets)
8787

88-
if "options" in presets:
89-
self.set(presets.options)
88+
if "options" in attr_presets:
89+
self.set(attr_presets.options)
9090

91-
if "components" in presets:
92-
for name, component in presets.components.items():
91+
if "components" in attr_presets:
92+
for name, component in attr_presets.components.items():
9393
rules = component.get("rules", None)
9494
if rules:
9595
self[name].ruler.enableOnly(rules)

0 commit comments

Comments
 (0)