Skip to content

Commit 99ebfac

Browse files
🔧 MAINTAIN: Don't allow None value for StateBase.src (#73)
Co-authored-by: Chris Sewell <[email protected]>
1 parent c55a243 commit 99ebfac

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

markdown_it/ruler.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ def __init__(self, src: str, md: "MarkdownIt", env: MutableMapping):
4141
self.md = md
4242

4343
@property
44-
def src(self):
44+
def src(self) -> str:
4545
return self._src
4646

4747
@src.setter
48-
def src(self, value):
48+
def src(self, value: str) -> None:
4949
self._src = value
50-
self.srcCharCode = (
51-
tuple(ord(c) for c in self.src) if self.src is not None else ()
52-
)
50+
self.srcCharCode = tuple(ord(c) for c in self.src)
5351

5452

5553
# The first positional arg is always a subtype of `StateBase`. Other

tests/test_api/test_main.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from markdown_it import MarkdownIt
22
from markdown_it.token import Token
3-
from markdown_it.rules_core import StateCore
43

54

65
def test_get_rules():
@@ -254,18 +253,6 @@ def test_emptyStr():
254253
]
255254

256255

257-
def test_noneState():
258-
md = MarkdownIt()
259-
state = StateCore(None, md, {}, [])
260-
261-
# Remove normalizing rule
262-
rules = md.core.ruler.get_active_rules()
263-
md.core.ruler.enableOnly(rules[rules.index("inline") :])
264-
265-
# Check that we can process None str with empty env and block_tokens
266-
md.core.process(state)
267-
268-
269256
def test_empty_env():
270257
"""Test that an empty `env` is mutated, not copied and mutated."""
271258
md = MarkdownIt()

0 commit comments

Comments
 (0)