Skip to content

Enable PYI059#15399

Merged
srittau merged 4 commits intopython:mainfrom
srittau:pyi059
May 7, 2026
Merged

Enable PYI059#15399
srittau merged 4 commits intopython:mainfrom
srittau:pyi059

Conversation

@srittau
Copy link
Copy Markdown
Collaborator

@srittau srittau commented Feb 9, 2026

No description provided.

@srittau
Copy link
Copy Markdown
Collaborator Author

srittau commented Feb 9, 2026

Part of #15358.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Copy Markdown
Member

This can only be done at the same time as removing the second branch here:

if sys.version_info >= (3, 10):
from .mixins import _LoopBoundMixin
else:
_LoopBoundMixin = object

@github-actions

This comment has been minimized.

@srittau
Copy link
Copy Markdown
Collaborator Author

srittau commented Feb 9, 2026

This can only be done at the same time as removing the second branch here:

ruff disagrees. :P

@AlexWaygood
Copy link
Copy Markdown
Member

AlexWaygood commented Feb 9, 2026

Ohhh, CI now passes here because you removed the pyright-3.9 CI check in the other PR. Hmm, but I'd still lean towards removing the second branch here at the same time as rearranging the order of the base classes? Pyright's previous complaint -- which is what prompted the noqa suppression -- was not a false positive. It was accurately flagging that it really is impossible for type checkers to infer the MRO of a class that inherits from two bases where the first is object and the second is Generic[_T]. It fails at runtime too; there's no way for C3 linearisation to succeed with that sequence of bases:

>>> from typing import Generic, TypeVar
>>> _T = TypeVar("_T")
>>> _LoopBoundMixin = object
>>> class Queue(_LoopBoundMixin, Generic[_T]): ...
... 
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    class Queue(_LoopBoundMixin, Generic[_T]): ...
TypeError: Cannot create a consistent method resolution order (MRO) for bases object, Generic

@srittau srittau added the status: deferred Issue or PR deferred until some precondition is fixed label Feb 9, 2026
@srittau
Copy link
Copy Markdown
Collaborator Author

srittau commented Feb 9, 2026

Makes sense. I've deferred this for now, and added it to #13782.

@srittau srittau marked this pull request as draft February 9, 2026 13:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 9, 2026

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau marked this pull request as ready for review May 7, 2026 18:35
@srittau srittau removed the status: deferred Issue or PR deferred until some precondition is fixed label May 7, 2026
@srittau srittau requested a review from AlexWaygood May 7, 2026 18:36
@srittau srittau merged commit c8c5e9e into python:main May 7, 2026
36 checks passed
@srittau srittau deleted the pyi059 branch May 7, 2026 22:10
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