Skip to content

Commit f7db503

Browse files
committed
fix: make typing-extension optional dependency
1 parent 6d04695 commit f7db503

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "mistune"
33
description = "A sane and fast Markdown parser with useful plugins and renderers"
44
authors = [{name = "Hsiaoming Yang", email="[email protected]"}]
55
dependencies = [
6-
"typing-extensions",
6+
"typing-extensions; python_version<'3.11'",
77
]
88
license = {text = "BSD-3-Clause"}
99
dynamic = ["version"]
@@ -18,7 +18,6 @@ classifiers = [
1818
"Operating System :: OS Independent",
1919
"Programming Language :: Python",
2020
"Programming Language :: Python :: 3",
21-
"Programming Language :: Python :: 3.7",
2221
"Programming Language :: Python :: 3.8",
2322
"Programming Language :: Python :: 3.9",
2423
"Programming Language :: Python :: 3.10",

src/mistune/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
Documentation: https://mistune.lepture.com/
99
"""
1010

11-
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
12-
13-
from typing_extensions import Literal
14-
11+
try:
12+
import typing_extensions
13+
except ImportError:
14+
pass
15+
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, Literal
1516
from .block_parser import BlockParser
1617
from .core import BaseRenderer, BlockState, InlineState
1718
from .inline_parser import InlineParser

src/mistune/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
Type,
1515
TypeVar,
1616
Union,
17+
Self,
1718
cast,
1819
)
19-
from typing_extensions import Self
2020

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

src/mistune/list_parser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import re
44
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Match
5-
6-
75
from .util import expand_leading_tab, expand_tab, strip_end
86

97
if TYPE_CHECKING:

src/mistune/renderers/html.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from typing import Any, ClassVar, Dict, Optional, Tuple
2-
3-
from typing_extensions import Literal
4-
1+
from typing import Any, ClassVar, Dict, Optional, Tuple, Literal
52
from ..core import BaseRenderer, BlockState
63
from ..util import escape as escape_text
74
from ..util import safe_entity, striptags

0 commit comments

Comments
 (0)