Skip to content

Update Ruff and use pyright for typechecking#320

Merged
sciyoshi merged 10 commits intomainfrom
updates
Mar 2, 2025
Merged

Update Ruff and use pyright for typechecking#320
sciyoshi merged 10 commits intomainfrom
updates

Conversation

@sciyoshi
Copy link
Copy Markdown
Collaborator

@sciyoshi sciyoshi commented Mar 2, 2025

Also switches to dependency groups for the dev dependencies.

@sciyoshi sciyoshi requested a review from Copilot March 2, 2025 03:19
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2025

Codecov Report

Attention: Patch coverage is 84.21053% with 15 lines in your changes missing coverage. Please review.

Project coverage is 82.76%. Comparing base (7f16822) to head (93ecfe6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
prosemirror/model/from_dom.py 76.19% 15 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #320   +/-   ##
=======================================
  Coverage   82.76%   82.76%           
=======================================
  Files          30       30           
  Lines        4161     4167    +6     
=======================================
+ Hits         3444     3449    +5     
- Misses        717      718    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors the parser rules to use stricter type annotations and dedicated classes (GenericParseRule, TagParseRule, and StyleParseRule), while also updating project configuration for dependency groups and switching from mypy to pyright for type‐checking.

  • Refactored parse rule types and updated associated methods
  • Updated workflow commands and dev dependencies in configuration files
  • Minor code cleanups and improved type safety across multiple files

Reviewed Changes

File Description
prosemirror/model/from_dom.py Updated imports, refined type annotations, and refactored parse rule classes
.github/workflows/test.yml Changed workflow commands to use uv sync and switched to pyright
pyproject.toml Switched to dependency groups and updated dev dependency versions
prosemirror/model/schema.py Minor refactor using dict.get and walrus operator
prosemirror/model/content.py Added dataclass annotations and improved type annotations
prosemirror/model/node.py Introduced walrus operator for cleaner leafText extraction
prosemirror/transform/replace.py Converted helper classes to dataclasses with slots
prosemirror/model/fragment.py Improved type casts and JSON input handling

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

prosemirror/model/from_dom.py:41

  • Changing the return type of rule_from_node to TagParseRule narrows its contract; please confirm that all consumers expect the more specific type and adjust accordingly if needed.
rule_from_node: Callable[[DOMNode], "TagParseRule"] | None = None

@sciyoshi sciyoshi requested a review from Copilot March 2, 2025 03:33
@sciyoshi sciyoshi marked this pull request as ready for review March 2, 2025 03:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR updates the project’s typechecking and linting setup by switching to pyright and a newer version of ruff, and it also reorganizes development dependencies into dependency groups. Key changes include updated type definitions for parse rules, improvements to error‐prone index accesses and tag handling in the DOM parser, and updates to CI workflows and dependency versions.

Reviewed Changes

File Description
prosemirror/model/from_dom.py Updated import statements, refined type annotations, and index access in cssselect usage.
.github/workflows/test.yml Expanded test coverage to include Python 3.13 and adjusted command invocations.
.github/workflows/release.yml Updated Python version and simplified build/publish commands with uv.
pyproject.toml Transitioned to dependency groups and updated dev dependency versions.
prosemirror/model/schema.py Minor updates to default attribute handling and mark group processing.
prosemirror/model/content.py Added type annotations and used dataclasses for improved clarity.
prosemirror/model/node.py Refined inline text handling with assignment expressions.
prosemirror/model/fragment.py Enforced stricter type casts when parsing JSON fragments.
prosemirror/transform/replace.py Converted several helper classes to dataclasses with slots for improved performance and clarity.

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

prosemirror/transform/replace.py:339

  • [nitpick] Consider using a more descriptive sentinel variable name (e.g., SENTINEL) instead of 'nothing' for clarity.
nothing_ = object()

@sciyoshi sciyoshi merged commit 67be2c5 into main Mar 2, 2025
7 checks passed
@sciyoshi sciyoshi deleted the updates branch March 2, 2025 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants