Skip to content

Formatter: Fix syntax error location in notebooks#16499

Merged
MichaReiser merged 1 commit intomainfrom
micha/fix-formatter-panic-syntax-error
Mar 4, 2025
Merged

Formatter: Fix syntax error location in notebooks#16499
MichaReiser merged 1 commit intomainfrom
micha/fix-formatter-panic-syntax-error

Conversation

@MichaReiser
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser commented Mar 4, 2025

Summary

Fixes #16476
fixes: #11453

We format notebooks cell by cell. That means, that offsets in parse errors are relative
to the cell and not the entire document. We didn't account for this fact
when emitting syntax errors for notebooks in the formatter.

This PR ensures that we correctly offset parse errors by the cell location.

Test Plan

Added test (it panicked before)

@MichaReiser MichaReiser added bug Something isn't working cli Related to the command-line interface labels Mar 4, 2025
@MichaReiser MichaReiser force-pushed the micha/fix-formatter-panic-syntax-error branch from 7bc83d9 to 4eceefc Compare March 4, 2025 15:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Copy Markdown
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

Thank you! I'll close #11456 one out then.

@MichaReiser MichaReiser merged commit 087d92c into main Mar 4, 2025
@MichaReiser MichaReiser deleted the micha/fix-formatter-panic-syntax-error branch March 4, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli Related to the command-line interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Formatter panic] Invalid syntax error location for Notebook with ruff format

2 participants