Skip to content

Support in/not in tests on sys.platform - #21913

Merged
hauntsaninja merged 2 commits into
python:masterfrom
JelleZijlstra:platformin
Sep 1, 2026
Merged

Support in/not in tests on sys.platform#21913
hauntsaninja merged 2 commits into
python:masterfrom
JelleZijlstra:platformin

Conversation

@JelleZijlstra

Copy link
Copy Markdown
Member

This is proposed for the spec in python/typing#2173. It is trivial to support in
mypy and seems useful, so let's add it.

This is proposed for the spec in python/typing#2173. It is trivial to support in
mypy and seems useful, so let's add it.
@github-actions

This comment has been minimized.

Comment thread mypy/reachability.py Outdated


def contains_tuple_or_set_of_strings(expr: Expression) -> tuple[str, ...] | None:
if isinstance(expr, (TupleExpr, SetExpr)) and all(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not have ListExpr

the related test is confusing, would be clearer as cast(list[str], []) or inside a function

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why not, I'll add it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also, not sure what related test you're referring to?

Comment thread test-data/unit/check-unreachable-code.test
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

meson (https://github.com/mesonbuild/meson)
+ mesonbuild/utils/platform.py:134: error: Unused "type: ignore" comment  [unused-ignore]

@hauntsaninja
hauntsaninja merged commit deda499 into python:master Sep 1, 2026
25 checks passed
@JelleZijlstra
JelleZijlstra deleted the platformin branch September 1, 2026 02:36
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