Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't error unnecessarily about new syntax in dependencies where we ignore errors anyways - #21883

Merged
ilevkivskyi merged 2 commits into
python:masterfrom
A5rocks:ignore-new-features
Sep 13, 2026
Merged

Don't error unnecessarily about new syntax in dependencies where we ignore errors anyways#21883
ilevkivskyi merged 2 commits into
python:masterfrom
A5rocks:ignore-new-features

Conversation

@A5rocks

@A5rocks A5rocks commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

This fixes #21178 (at least my own root cause for it). This is actually a bit trickier than I thought (you can read that issue to see what I thought would work, which was naive!). However, even though we use the ast module and cannot make the errors nonblocking, we can work around the root cause of that issue i.e. that new features in dependencies can cause mypy to fail.

@A5rocks
A5rocks force-pushed the ignore-new-features branch from dd534bf to 0a7f41f Compare August 22, 2026 04:52
@A5rocks

A5rocks commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

I would be happy to explain more about the root cause, especially since I never actually made an issue particular to it, but essentially Trio has a lockfile (https://github.com/python-trio/trio/blob/main/test-requirements.txt) that conditionally has newer Sphinx versions that use new typing features. In particular, when I develop locally with my 3.14 Python, after a uv pip install <lockfile>, I get this:

a5rocks@whimsy ~/D/trio> uv run mypy
.venv/lib/python3.14/site-packages/sphinx/util/typing.py:29: error: Type statement is only supported in Python 3.12 and greater  [syntax]
Found 1 error in 1 file (errors prevented further checking)

and this has bothered me forever :-)

@github-actions

This comment has been minimized.

@A5rocks
A5rocks force-pushed the ignore-new-features branch from 0a7f41f to 8187c82 Compare August 22, 2026 05:24
@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. ✅

@ilevkivskyi

Copy link
Copy Markdown
Member

How does this work with the new parser? Or does this issue only affect the old parser?

@A5rocks

A5rocks commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Idk, I imagine it only affects old parser since I remember ruff's parser does some error recovery (and so hitting a syntax error won't block parsing the rest)

@ilevkivskyi

Copy link
Copy Markdown
Member

@A5rocks it looks like there is an epidemic of people not knowing what is going on in their PRs :-) Can you try the new parser? Also please test both with --native-parser and --no-native-parser.

@A5rocks

A5rocks commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

On master the test case in this PR succeeds, though there's a bug (I think) in the test suite code that requires me to pass TEST_NATIVE_PARSER=True as an environment variable. I think it should be options.native_parser = options.native_parser or bool(os.environ.get("TEST_NATIVE_PARSER")) so tests can add a --native-parser flag to themselves?

So anyways, yes, it seems like only the old parser needs this PR.

@ilevkivskyi

Copy link
Copy Markdown
Member

OK, I am actually deleting this env var logic in my PR, so I can just merge this, and then the test will naturally switch to new parser when my PR is merged.

@ilevkivskyi
ilevkivskyi merged commit 75b6d3c into python:master Sep 13, 2026
25 checks passed
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.

python-version based syntax checks should not block

2 participants