Skip to content

Improve negative narrowing in contains checks - #22242

Merged
hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:simplify
Oct 21, 2026
Merged

hauntsaninja merged 1 commit into
python:masterfrom
hauntsaninja:simplify

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

This was an accident of history, I think we can just delegate to narrow_type_by_identity_equality entirely

This was an accident of history, I think we can just delegate to
narrow_type_by_identity_equality entirely
@github-actions

Copy link
Copy Markdown
Contributor

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

discord.py (https://github.com/Rapptz/discord.py)
- discord/components.py:1750: error: Missing return statement  [return]

pydantic (https://github.com/pydantic/pydantic)
- pydantic/v1/types.py:704: error: Unsupported operand types for >= ("Literal['n']" and "int")  [operator]
- pydantic/v1/types.py:704: error: Unsupported operand types for >= ("Literal['N']" and "int")  [operator]
- pydantic/v1/types.py:704: error: Unsupported operand types for >= ("Literal['F']" and "int")  [operator]
- pydantic/v1/types.py:704: note: Left operand is of type "Literal['n', 'N', 'F'] | int"
- pydantic/v1/types.py:706: error: Unsupported operand types for + ("int" and "Literal['n']")  [operator]
- pydantic/v1/types.py:706: error: Unsupported operand types for + ("int" and "Literal['N']")  [operator]
- pydantic/v1/types.py:706: error: Unsupported operand types for + ("int" and "Literal['F']")  [operator]
- pydantic/v1/types.py:706: note: Right operand is of type "Literal['n', 'N', 'F'] | int"
- pydantic/v1/types.py:714: error: Argument 1 to "abs" has incompatible type "Literal['n', 'N', 'F'] | int"; expected "SupportsAbs[int]"  [arg-type]
- pydantic/v1/types.py:715: error: Argument 1 to "abs" has incompatible type "Literal['n', 'N', 'F'] | int"; expected "SupportsAbs[int]"  [arg-type]
- pydantic/v1/types.py:718: error: Argument 1 to "abs" has incompatible type "Literal['n', 'N', 'F'] | int"; expected "SupportsAbs[int]"  [arg-type]

pytest-autoprofile (https://gitlab.com/TTsangSC/pytest-autoprofile)
+ tests/test_subprocess.py:382: error: Redundant cast to "tuple[Literal[0, 1, 2], Literal[0, 1, 2]]"  [redundant-cast]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/_epub_base.py:34:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
- sphinx/testing/util.py:80:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ sphinx/transforms/post_transforms/code.py:9:1: note: (or run "mypy --install-types" to install all missing stub packages)
+ sphinx/transforms/post_transforms/code.py:9:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
- sphinx/cmd/build.py:460:1: note: Hint: "python3 -m pip install types-Pygments"
- sphinx/cmd/build.py:460:1: note: (or run "mypy --install-types" to install all missing stub packages)
- sphinx/application.py:48:1: note: Hint: "python3 -m pip install types-Pygments"
- sphinx/application.py:48:1: note: (or run "mypy --install-types" to install all missing stub packages)
- sphinx/application.py:48:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

@hauntsaninja
hauntsaninja merged commit 62d0dec into python:master Oct 21, 2026
25 checks passed
@hauntsaninja
hauntsaninja deleted the simplify branch October 21, 2026 07:29
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