Skip to content

Report incompatible ast-serialize versions clearly#21523

Open
sjh9714 wants to merge 2 commits into
python:masterfrom
sjh9714:fix-ast-serialize-version-error
Open

Report incompatible ast-serialize versions clearly#21523
sjh9714 wants to merge 2 commits into
python:masterfrom
sjh9714:fix-ast-serialize-version-error

Conversation

@sjh9714
Copy link
Copy Markdown

@sjh9714 sjh9714 commented May 20, 2026

Fixes #21412.

This checks the installed ast-serialize distribution version before the native parser serializes AST data. Incompatible versions now produce a clear mypy error instead of letting parallel checking deserialize incompatible data and report an internal error.

The check is cached after a successful validation, and missing distribution metadata keeps the existing manual/native-parser behavior unchanged.

Testing:

  • .venv/bin/python -m pytest -n0 mypy/test/test_nativeparse.py -k ast_serialize_version -q
  • .venv/bin/python -m pytest -n0 mypy/test/test_nativeparse.py -q
  • .venv/bin/python runtests.py self
  • PATH="$PWD/.venv/bin:$PATH" .venv/bin/python runtests.py lint
  • git diff --check
  • Verified a temporary venv with ast-serialize==0.2.3 reports mypy: error: ast-serialize 0.2.3 is too old; mypy requires ast-serialize>=0.5.0,<1.0.0 for mypy --num-workers=2.

Note: I used Codex while preparing this change, and reviewed the final diff and ran the listed checks locally.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

Provide better error for wrong ast_serialize version with parallel checking

1 participant