Skip to content

Conversation

@sterliakov
Copy link
Collaborator

@sterliakov sterliakov commented Oct 26, 2025

Fixes #16573.
Fixes #3031.

When we infer something with Never as a replacement for a partial type, we cannot ignore that result entirely: if we do that, any use of that variable down the road will still refer to partial<None>, causing reachability issues and unexpected partials leaks.

@github-actions

This comment has been minimized.

@sterliakov
Copy link
Collaborator Author

All primer hits are correct - empty list in sympy, queue.Queue without generic param in pymongo, and "Item None of ..." is a true positive that was not emitted before (probably due to partial callee type).

@sterliakov sterliakov marked this pull request as ready for review October 26, 2025 19:17
@sterliakov sterliakov requested a review from JukkaL October 26, 2025 19:18
@sterliakov
Copy link
Collaborator Author

(cc @JukkaL - you recently authored --allow-redefinition-new which is very close to this change)

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

I think this is actually the correct fix (unless @JukkaL disagrees), I however have a suggestion on the fallback behavior.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

LG, couple more comments.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/synchronous/topology.py:114: error: Need type annotation for "_events"  [var-annotated]
+ pymongo/synchronous/topology.py:129: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_opened"  [union-attr]
+ pymongo/synchronous/topology.py:148: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/synchronous/topology.py:164: error: Item "None" of "_EventListeners | None" has no attribute "publish_server_opened"  [union-attr]
+ pymongo/synchronous/topology.py:496: error: Item "None" of "_EventListeners | None" has no attribute "publish_server_description_changed"  [union-attr]
+ pymongo/synchronous/topology.py:508: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/synchronous/topology.py:575: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/synchronous/topology.py:734: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/synchronous/topology.py:742: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_closed"  [union-attr]
+ pymongo/asynchronous/topology.py:114: error: Need type annotation for "_events"  [var-annotated]
+ pymongo/asynchronous/topology.py:129: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_opened"  [union-attr]
+ pymongo/asynchronous/topology.py:148: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/asynchronous/topology.py:164: error: Item "None" of "_EventListeners | None" has no attribute "publish_server_opened"  [union-attr]
+ pymongo/asynchronous/topology.py:496: error: Item "None" of "_EventListeners | None" has no attribute "publish_server_description_changed"  [union-attr]
+ pymongo/asynchronous/topology.py:508: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/asynchronous/topology.py:575: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/asynchronous/topology.py:736: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_description_changed"  [union-attr]
+ pymongo/asynchronous/topology.py:744: error: Item "None" of "_EventListeners | None" has no attribute "publish_topology_closed"  [union-attr]

sympy (https://github.com/sympy/sympy)
+ sympy/core/add.py:218: error: Need type annotation for "rv"  [var-annotated]

@ilevkivskyi ilevkivskyi merged commit 054f721 into python:master Oct 28, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpectedly encountered partial type Don't silently ignore some partial types

2 participants