diff --git a/prosemirror/model/content.py b/prosemirror/model/content.py index 31d4b84..b1a91ae 100644 --- a/prosemirror/model/content.py +++ b/prosemirror/model/content.py @@ -86,7 +86,7 @@ def match_fragment( ) -> Optional["ContentMatch"]: if end is None: end = frag.child_count - cur: "ContentMatch" | None = self + cur: ContentMatch | None = self i = start while cur and i < end: cur = cur.match_type(frag.child(i).type) diff --git a/prosemirror/model/fragment.py b/prosemirror/model/fragment.py index ffe49a1..194f154 100644 --- a/prosemirror/model/fragment.py +++ b/prosemirror/model/fragment.py @@ -126,7 +126,7 @@ def cut(self, from_: int, to: int | None = None) -> "Fragment": to = self.size if from_ == 0 and to == self.size: return self - result: list["Node"] = [] + result: list[Node] = [] size = 0 if to <= from_: return Fragment(result, size) @@ -273,7 +273,7 @@ def from_json(cls, schema: "Schema[Any, Any]", value: JSON) -> "Fragment": def from_array(cls, array: list["Node"]) -> "Fragment": if not array: return cls.empty - joined: list["Node"] | None = None + joined: list[Node] | None = None size = 0 for i in range(len(array)): node = array[i] diff --git a/prosemirror/model/mark.py b/prosemirror/model/mark.py index 41e878d..4d96711 100644 --- a/prosemirror/model/mark.py +++ b/prosemirror/model/mark.py @@ -15,7 +15,7 @@ def __init__(self, type: "MarkType", attrs: Attrs) -> None: self.attrs = attrs def add_to_set(self, set: list["Mark"]) -> list["Mark"]: - copy: list["Mark"] | None = None + copy: list[Mark] | None = None placed = False for i in range(len(set)): other = set[i] diff --git a/prosemirror/model/node.py b/prosemirror/model/node.py index 1135d4e..aa53b3b 100644 --- a/prosemirror/model/node.py +++ b/prosemirror/model/node.py @@ -267,7 +267,7 @@ def can_replace( if end is None: end = replacement.child_count one = self.content_match_at(from_).match_fragment(replacement, start, end) - two: "ContentMatch" | None = None + two: ContentMatch | None = None if one: two = one.match_fragment(self.content, to) if not two or not two.valid_end: @@ -287,7 +287,7 @@ def can_replace_with( if marks and not self.type.allows_marks(marks): return False start = self.content_match_at(from_).match_type(type) - end: "ContentMatch" | None = None + end: ContentMatch | None = None if start: end = start.match_fragment(self.content, to) return end.valid_end if end else False diff --git a/prosemirror/model/replace.py b/prosemirror/model/replace.py index f1922a3..94c70ef 100644 --- a/prosemirror/model/replace.py +++ b/prosemirror/model/replace.py @@ -246,7 +246,7 @@ def replace_three_way( ) -> Fragment: open_start = joinable(from_, start, depth + 1) if from_.depth > depth else None open_end = joinable(end, to, depth + 1) if to.depth > depth else None - content: list["Node"] = [] + content: list[Node] = [] add_range(None, from_, depth, content) if open_start and open_end and start.index(depth) == end.index(depth): check_join(open_start, open_end) @@ -268,7 +268,7 @@ def replace_three_way( def replace_two_way(from_: "ResolvedPos", to: "ResolvedPos", depth: int) -> Fragment: - content: list["Node"] = [] + content: list[Node] = [] add_range(None, from_, depth, content) if from_.depth > depth: type = joinable(from_, to, depth + 1) diff --git a/prosemirror/model/resolvedpos.py b/prosemirror/model/resolvedpos.py index 2aeba5a..b454d69 100644 --- a/prosemirror/model/resolvedpos.py +++ b/prosemirror/model/resolvedpos.py @@ -188,7 +188,7 @@ def resolve(cls, doc: "Node", pos: int) -> "ResolvedPos": if not (pos >= 0 and pos <= doc.content.size): msg = f"Position {pos} out of range" raise ValueError(msg) - path: list["Node" | int] = [] + path: list[Node | int] = [] start = 0 parent_offset = pos node = doc diff --git a/prosemirror/model/schema.py b/prosemirror/model/schema.py index 1ab5ab2..e4d26b8 100644 --- a/prosemirror/model/schema.py +++ b/prosemirror/model/schema.py @@ -212,7 +212,7 @@ def compile( nodes: dict["Nodes", "NodeSpec"], schema: "Schema[Nodes, Marks]", ) -> dict["Nodes", "NodeType"]: - result: dict["Nodes", "NodeType"] = {} + result: dict[Nodes, NodeType] = {} for name, spec in nodes.items(): result[name] = NodeType(name, schema, spec) diff --git a/prosemirror/transform/__init__.py b/prosemirror/transform/__init__.py index 4d27c97..6e348ad 100644 --- a/prosemirror/transform/__init__.py +++ b/prosemirror/transform/__init__.py @@ -5,6 +5,7 @@ close_fragment, covered_depths, fits_trivially, + replace_step, ) from .replace_step import ReplaceAroundStep, ReplaceStep from .step import Step, StepResult @@ -45,5 +46,4 @@ "join_point", "lift_target", "replace_step", - "replace_step", ] diff --git a/tests/conftest.py b/tests/conftest.py index 33f7dd0..032c924 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import pytest -@pytest.fixture() +@pytest.fixture def ist(): def ist(a, b=None, key=None): if key is None: diff --git a/tests/prosemirror_model/tests/test_resolve.py b/tests/prosemirror_model/tests/test_resolve.py index 4d4caf4..b8c7238 100644 --- a/tests/prosemirror_model/tests/test_resolve.py +++ b/tests/prosemirror_model/tests/test_resolve.py @@ -71,7 +71,7 @@ def test_resolvedpos_str(pos, result): assert str(test_doc.resolve(pos)) == result -@pytest.fixture() +@pytest.fixture def doc_for_pos_at_index(): return doc(blockquote(p("one"), blockquote(p("two ", em("three")), p("four")))) diff --git a/tests/prosemirror_transform/tests/conftest.py b/tests/prosemirror_transform/tests/conftest.py index 8161c6a..590a4b1 100644 --- a/tests/prosemirror_transform/tests/conftest.py +++ b/tests/prosemirror_transform/tests/conftest.py @@ -17,7 +17,7 @@ p = out["p"] -@pytest.fixture() +@pytest.fixture def test_mapping(): def t_mapping(mapping, *cases): inverted = mapping.invert() @@ -32,7 +32,7 @@ def t_mapping(mapping, *cases): return t_mapping -@pytest.fixture() +@pytest.fixture def make_mapping(): def mk(*args): mapping = Mapping() @@ -47,7 +47,7 @@ def mk(*args): return mk -@pytest.fixture() +@pytest.fixture def test_del(): def t_del(mapping: Mapping, pos: int, side: int, flags: str): r = mapping.map_result(pos, side) @@ -65,7 +65,7 @@ def t_del(mapping: Mapping, pos: int, side: int, flags: str): return t_del -@pytest.fixture() +@pytest.fixture def make_step(): return _make_step @@ -82,7 +82,7 @@ def _make_step(from_: int, to: int, val: str | None) -> Step: ) -@pytest.fixture() +@pytest.fixture def test_doc(): return doc(p("foobar")) @@ -90,7 +90,7 @@ def test_doc(): _test_doc = doc(p("foobar")) -@pytest.fixture() +@pytest.fixture def test_transform(): def invert(transform): out = Transform(transform.doc)