File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ from collections .abc import Mapping
4
+ import sys
5
+ from typing import Any
6
+
7
+ if sys .version_info >= (3 , 10 ):
8
+ DATACLASS_KWARGS : Mapping [str , Any ] = {"slots" : True }
9
+ else :
10
+ DATACLASS_KWARGS : Mapping [str , Any ] = {}
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class Ruler
21
21
from dataclasses import dataclass , field
22
22
from typing import TYPE_CHECKING
23
23
24
+ from markdown_it ._compat import DATACLASS_KWARGS
25
+
24
26
if TYPE_CHECKING :
25
27
from markdown_it import MarkdownIt
26
28
@@ -50,7 +52,7 @@ def src(self, value: str) -> None:
50
52
RuleFunc = Callable
51
53
52
54
53
- @dataclass ()
55
+ @dataclass (** DATACLASS_KWARGS )
54
56
class Rule :
55
57
name : str
56
58
enabled : bool
Original file line number Diff line number Diff line change 5
5
from dataclasses import dataclass
6
6
from typing import TYPE_CHECKING
7
7
8
+ from .._compat import DATACLASS_KWARGS
8
9
from ..common .utils import isMdAsciiPunct , isPunctChar , isWhiteSpace
9
10
from ..ruler import StateBase
10
11
from ..token import Token
13
14
from markdown_it import MarkdownIt
14
15
15
16
16
- @dataclass ()
17
+ @dataclass (** DATACLASS_KWARGS )
17
18
class Delimiter :
18
19
# Char code of the starting marker (number).
19
20
marker : int
Original file line number Diff line number Diff line change 5
5
from typing import Any
6
6
import warnings
7
7
8
+ from markdown_it ._compat import DATACLASS_KWARGS
9
+
8
10
9
11
def convert_attrs (value : Any ) -> Any :
10
12
"""Convert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict.
@@ -18,7 +20,7 @@ def convert_attrs(value: Any) -> Any:
18
20
return value
19
21
20
22
21
- @dc .dataclass ()
23
+ @dc .dataclass (** DATACLASS_KWARGS )
22
24
class Token :
23
25
24
26
type : str
You can’t perform that action at this time.
0 commit comments