Skip to content

Unsoundly narrow away from None with custom eq#20756

Merged
hauntsaninja merged 1 commit intopython:masterfrom
hauntsaninja:narrow88
Feb 6, 2026
Merged

Unsoundly narrow away from None with custom eq#20756
hauntsaninja merged 1 commit intopython:masterfrom
hauntsaninja:narrow88

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Feb 6, 2026

With #20754 we see some primer hits where this unsoundness is beneficial

Closes #15764

In python#20754 we see some primer hits where this unsoundness is beneficial
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

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

pip (https://github.com/pypa/pip)
- src/pip/_internal/resolution/resolvelib/candidates.py:293: error: Item "None" of "Link | None" has no attribute "is_wheel"  [union-attr]
- src/pip/_internal/resolution/resolvelib/candidates.py:293: error: Item "None" of "Link | None" has no attribute "is_file"  [union-attr]
- src/pip/_internal/resolution/resolvelib/candidates.py:294: error: Item "None" of "Link | None" has no attribute "filename"  [union-attr]
- src/pip/_internal/resolution/resolvelib/candidates.py:305: error: Item "None" of "Link | None" has no attribute "is_wheel"  [union-attr]
- src/pip/_internal/resolution/resolvelib/candidates.py:306: error: Item "None" of "Link | None" has no attribute "is_file"  [union-attr]

schema_salad (https://github.com/common-workflow-language/schema_salad)
- schema_salad/tests/test_examples.py: note: In function "test_scoped_id":
- schema_salad/tests/test_examples.py:395:23: error: Argument 2 to "makerdf" has incompatible type "int | float | str | CommentedMap | CommentedSeq | None"; expected "CommentedMap | float | str | CommentedSeq"  [arg-type]
- schema_salad/tests/test_examples.py:408:23: error: Argument 2 to "makerdf" has incompatible type "int | float | str | CommentedMap | CommentedSeq | None"; expected "CommentedMap | float | str | CommentedSeq"  [arg-type]
- schema_salad/tests/test_examples.py:421:23: error: Argument 2 to "makerdf" has incompatible type "int | float | str | CommentedMap | CommentedSeq | None"; expected "CommentedMap | float | str | CommentedSeq"  [arg-type]
- schema_salad/tests/test_examples.py:434:23: error: Argument 2 to "makerdf" has incompatible type "int | float | str | CommentedMap | CommentedSeq | None"; expected "CommentedMap | float | str | CommentedSeq"  [arg-type]

@hauntsaninja hauntsaninja merged commit 06a5f5d into python:master Feb 6, 2026
23 checks passed
@hauntsaninja hauntsaninja deleted the narrow88 branch February 6, 2026 22:42
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.

Overriding __eq__ can break Optional/Literal narrowing assumptions

2 participants