Skip to content

Commit

Permalink
fix: make typing-extension optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Oct 24, 2024
1 parent 6d04695 commit f7db503
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "mistune"
description = "A sane and fast Markdown parser with useful plugins and renderers"
authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}]
dependencies = [
"typing-extensions",
"typing-extensions; python_version<'3.11'",
]
license = {text = "BSD-3-Clause"}
dynamic = ["version"]
Expand All @@ -18,7 +18,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
9 changes: 5 additions & 4 deletions src/mistune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
Documentation: https://mistune.lepture.com/
"""

from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

from typing_extensions import Literal

try:
import typing_extensions
except ImportError:
pass
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, Literal
from .block_parser import BlockParser
from .core import BaseRenderer, BlockState, InlineState
from .inline_parser import InlineParser
Expand Down
2 changes: 1 addition & 1 deletion src/mistune/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
Type,
TypeVar,
Union,
Self,
cast,
)
from typing_extensions import Self

_LINE_END = re.compile(r'\n|$')

Expand Down
2 changes: 0 additions & 2 deletions src/mistune/list_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import re
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Match


from .util import expand_leading_tab, expand_tab, strip_end

if TYPE_CHECKING:
Expand Down
5 changes: 1 addition & 4 deletions src/mistune/renderers/html.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from typing import Any, ClassVar, Dict, Optional, Tuple

from typing_extensions import Literal

from typing import Any, ClassVar, Dict, Optional, Tuple, Literal
from ..core import BaseRenderer, BlockState
from ..util import escape as escape_text
from ..util import safe_entity, striptags
Expand Down

0 comments on commit f7db503

Please sign in to comment.