Skip to content

Report Pyflakes warning ranges in UTF-16 code units - #740

Open
Boulea7 wants to merge 1 commit into
python-lsp:developfrom
Boulea7:fix/pyflakes-diagnostic-utf16
Open

Boulea7 wants to merge 1 commit into
python-lsp:developfrom
Boulea7:fix/pyflakes-diagnostic-utf16

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 2, 2026

Copy link
Copy Markdown

Refs #343.

On a line containing "😀"; missing with no trailing newline, Pyflakes reports the undefined name at columns 8–12. The editor expects UTF-16 columns 6–13. The plugin now converts the AST byte offset to UTF-16 and ends the diagnostic before the line ending. It uses Python’s physical lines and the text received from the editor, including when a file declares a legacy encoding.

The regression tests cover wide and combining characters, BOMs, CRLF, and source encoding declarations. The full suite passed on Python 3.12 and 3.14 with the repository’s CI settings (228 passed, 10 skipped on each). A running Python 3.14 stdio server returned the expected UTF-16 ranges in all 18 editor cases.

OpenAI Codex prepared and tested this change. A separate Codex review verified the diagnostic ranges and existing encoding errors through stdio.

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.

1 participant