Skip to content

Commit

Permalink
style: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Dec 3, 2024
1 parent 103bc1d commit 3562fbb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/markdown_exec/formatters/_exec_python.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Special module without future annotations for executing Python code."""

from typing import Any, Dict, Optional
from typing import Any, Optional


def exec_python(code: str, filename: str, exec_globals: Optional[Dict[str, Any]] = None) -> None:
def exec_python(code: str, filename: str, exec_globals: Optional[dict[str, Any]] = None) -> None:
compiled = compile(code, filename=filename, mode="exec")
exec(compiled, exec_globals) # noqa: S102
4 changes: 3 additions & 1 deletion src/markdown_exec/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
from contextlib import contextmanager
from textwrap import indent
from typing import TYPE_CHECKING, Any, Callable, Iterator
from typing import TYPE_CHECKING, Any, Callable
from uuid import uuid4

from markupsafe import Markup
Expand All @@ -14,6 +14,8 @@
from markdown_exec.rendering import MarkdownConverter, add_source, code_block

if TYPE_CHECKING:
from collections.abc import Iterator

from markdown.core import Markdown

logger = get_logger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/markdown_exec/formatters/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _run_python(
id: str | None = None, # noqa: A002
**extra: str,
) -> str:
title = extra.get("title", None)
title = extra.get("title")
code_block_id = _code_block_id(id, session, title)
_code_blocks[code_block_id] = code.split("\n")
exec_globals = _sessions_globals[session] if session else {}
Expand Down
4 changes: 3 additions & 1 deletion src/markdown_exec/mkdocs_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import os
from pathlib import Path
from typing import TYPE_CHECKING, Any, MutableMapping
from typing import TYPE_CHECKING, Any

from mkdocs.config import config_options
from mkdocs.config.base import Config
Expand All @@ -18,6 +18,8 @@
from markdown_exec.rendering import MarkdownConverter, markdown_config

if TYPE_CHECKING:
from collections.abc import MutableMapping

from jinja2 import Environment
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import Files
Expand Down
7 changes: 4 additions & 3 deletions src/markdown_exec/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

from contextlib import contextmanager
from functools import lru_cache
from functools import cache
from textwrap import indent
from typing import TYPE_CHECKING, Any, Iterator
from typing import TYPE_CHECKING, Any

from markdown import Markdown
from markupsafe import Markup
Expand All @@ -18,6 +18,7 @@
)

if TYPE_CHECKING:
from collections.abc import Iterator
from xml.etree.ElementTree import Element

from markdown import Extension
Expand Down Expand Up @@ -180,7 +181,7 @@ def reset(self) -> None:
# XML entities that get stashed in headings.


@lru_cache(maxsize=None)
@cache
def _register_headings_processors(md: Markdown) -> None:
md.treeprocessors.register(
InsertHeadings(md),
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from markdown_exec import formatter, formatters, validator


@pytest.fixture()
@pytest.fixture
def md() -> Markdown:
"""Return a Markdown instance.
Expand Down

0 comments on commit 3562fbb

Please sign in to comment.