Skip to content

Commit

Permalink
Loosen up config typing
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkinj1 committed Oct 21, 2020
1 parent f738760 commit 2eccc3d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions markdown_it/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from contextlib import contextmanager
from typing import Any, Callable, Dict, List, Optional, Union
from typing import Any, Callable, Dict, List, Mapping, Optional, Union

from . import helpers, presets # noqa F401
from .common import utils # noqa F401
Expand All @@ -23,7 +23,7 @@

class MarkdownIt:
def __init__(
self, config: Union[str, AttrDict] = "commonmark", renderer_cls=RendererHTML
self, config: Union[str, Mapping] = "commonmark", renderer_cls=RendererHTML
):
"""Main parser class
Expand Down Expand Up @@ -65,7 +65,7 @@ def set(self, options):
"""
self.options = options

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

if "options" in presets:
self.set(presets.options)
if "options" in attr_presets:
self.set(attr_presets.options)

if "components" in presets:
for name, component in presets.components.items():
if "components" in attr_presets:
for name, component in attr_presets.components.items():
rules = component.get("rules", None)
if rules:
self[name].ruler.enableOnly(rules)
Expand Down

0 comments on commit 2eccc3d

Please sign in to comment.