Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install uv
- run: uv venv
- run: uv pip install --requirement pyproject.toml
- run: uv pip install setuptools setuptools-scm wheel build
- run: .venv/bin/python -m build --no-isolation
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- run: uv build
- run: uv publish
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: pip install uv
- run: uv venv
- run: uv pip install --requirement pyproject.toml --all-extras
- run: .venv/bin/pytest --cov=./prosemirror/
- run: .venv/bin/codecov
- run: uv sync
- run: uv run pytest --cov=./prosemirror/
- run: uv run codecov
if: matrix.python-version == '3.11'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -31,9 +31,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: pip install uv
- run: uv venv
- run: uv pip install --requirement pyproject.toml --all-extras
- run: .venv/bin/ruff format --check prosemirror tests
- run: .venv/bin/ruff check prosemirror tests
- run: .venv/bin/mypy prosemirror
- run: uv sync
- run: uv run ruff format --check prosemirror tests
- run: uv run ruff check prosemirror tests
- run: uv run pyright prosemirror
19 changes: 7 additions & 12 deletions prosemirror/model/content.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from dataclasses import dataclass
from functools import cmp_to_key, reduce
from typing import (
TYPE_CHECKING,
Expand All @@ -18,23 +19,17 @@
from .schema import NodeType


@dataclass
class MatchEdge:
type: "NodeType"
next: "ContentMatch"

def __init__(self, type: "NodeType", next: "ContentMatch") -> None:
self.type = type
self.next = next


@dataclass
class WrapCacheEntry:
target: "NodeType"
computed: list["NodeType"] | None

def __init__(self, target: "NodeType", computed: list["NodeType"] | None) -> None:
self.target = target
self.computed = computed


class Active(TypedDict):
match: "ContentMatch"
Expand Down Expand Up @@ -118,7 +113,7 @@ def fill_before(
to_end: bool = False,
start_index: int = 0,
) -> Fragment | None:
seen = [self]
seen: list[ContentMatch] = [self]

def search(match: ContentMatch, types: list["NodeType"]) -> Fragment | None:
nonlocal seen
Expand Down Expand Up @@ -289,7 +284,7 @@ class NameExpr(TypedDict):


def parse_expr(stream: TokenStream) -> Expr:
exprs = []
exprs: list[Expr] = []
while True:
exprs.append(parse_expr_seq(stream))
if not stream.eat("|"):
Expand All @@ -300,7 +295,7 @@ def parse_expr(stream: TokenStream) -> Expr:


def parse_expr_seq(stream: TokenStream) -> Expr:
exprs = []
exprs: list[Expr] = []
while True:
exprs.append(parse_expr_subscript(stream))
next_ = stream.next()
Expand All @@ -312,7 +307,7 @@ def parse_expr_seq(stream: TokenStream) -> Expr:


def parse_expr_subscript(stream: TokenStream) -> Expr:
expr = parse_expr_atom(stream)
expr: Expr = parse_expr_atom(stream)
while True:
if stream.eat("+"):
expr = {"type": "plus", "expr": expr}
Expand Down
8 changes: 4 additions & 4 deletions prosemirror/model/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cast,
)

from prosemirror.utils import JSON, JSONList, text_length
from prosemirror.utils import JSON, JSONDict, JSONList, text_length

if TYPE_CHECKING:
from prosemirror.model.schema import Schema
Expand Down Expand Up @@ -89,8 +89,8 @@ def iteratee(
elif node.is_leaf:
if leaf_text:
text.append(leaf_text(node) if callable(leaf_text) else leaf_text)
elif node.type.spec.get("leafText") is not None:
text.append(node.type.spec["leafText"](node))
elif (node_leaf_text := node.type.spec.get("leafText")) is not None:
text.append(node_leaf_text(node))
separated = not block_separator
elif not separated and node.is_block:
text.append(block_separator)
Expand Down Expand Up @@ -267,7 +267,7 @@ def from_json(cls, schema: "Schema[Any, Any]", value: JSON) -> "Fragment":
msg = "Invalid input for Fragment.from_json"
raise ValueError(msg)

return cls([schema.node_from_json(item) for item in value])
return cls([schema.node_from_json(cast(JSONDict, item)) for item in value])

@classmethod
def from_array(cls, array: list["Node"]) -> "Fragment":
Expand Down
Loading