Skip to content

Commit

Permalink
fix ruff lint
Browse files Browse the repository at this point in the history
  • Loading branch information
p7g committed Aug 20, 2024
1 parent 3353178 commit 5a5cc70
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion prosemirror/model/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions prosemirror/model/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion prosemirror/model/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions prosemirror/model/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions prosemirror/model/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion prosemirror/model/resolvedpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion prosemirror/model/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion prosemirror/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
close_fragment,
covered_depths,
fits_trivially,
replace_step,
)
from .replace_step import ReplaceAroundStep, ReplaceStep
from .step import Step, StepResult
Expand Down Expand Up @@ -45,5 +46,4 @@
"join_point",
"lift_target",
"replace_step",
"replace_step",
]
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def ist():
def ist(a, b=None, key=None):
if key is None:
Expand Down
2 changes: 1 addition & 1 deletion tests/prosemirror_model/tests/test_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))

Expand Down
12 changes: 6 additions & 6 deletions tests/prosemirror_transform/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
p = out["p"]


@pytest.fixture()
@pytest.fixture
def test_mapping():
def t_mapping(mapping, *cases):
inverted = mapping.invert()
Expand All @@ -32,7 +32,7 @@ def t_mapping(mapping, *cases):
return t_mapping


@pytest.fixture()
@pytest.fixture
def make_mapping():
def mk(*args):
mapping = Mapping()
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -82,15 +82,15 @@ def _make_step(from_: int, to: int, val: str | None) -> Step:
)


@pytest.fixture()
@pytest.fixture
def test_doc():
return doc(p("foobar"))


_test_doc = doc(p("foobar"))


@pytest.fixture()
@pytest.fixture
def test_transform():
def invert(transform):
out = Transform(transform.doc)
Expand Down

0 comments on commit 5a5cc70

Please sign in to comment.