This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Minor repr error in typing.TypeVar.__ror__()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: JelleZijlstra, gvanrossum, kj, larry, levkivskyi
Priority: low Keywords: patch

Created on 2021-04-08 11:09 by larry, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25339 merged JelleZijlstra, 2021-04-11 02:17
Messages (3)
msg390524 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2021-04-08 11:09
The implementation of the | operator for TypeVar objects is as follows:

    def __or__(self, right):
        return Union[self, right]

    def __ror__(self, right):
        return Union[self, right]

I think the implementation of __ror__ is ever-so-slightly inaccurate.  Shouldn't it be this?

    def __ror__(self, left):
        return Union[left, self]

I assume this wouldn't affect runtime behavior, as unions are sets and are presumably unordered.  The only observable difference should be in the repr() (and only then if both are non-None), as this reverses the elements.  The repr for Union does preserve the order of the elements it contains, so it's visible to the user there.
msg390540 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-08 18:26
Yes.--
--Guido (mobile)
msg390764 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-11 03:00
New changeset 9045919bfa820379a66ea67219f79ef6d9ecab49 by Jelle Zijlstra in branch 'master':
bpo-43772: Fix TypeVar.__ror__ (GH-25339)
https://github.com/python/cpython/commit/9045919bfa820379a66ea67219f79ef6d9ecab49
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 87938
2021-04-11 03:00:19gvanrossumsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-04-11 03:00:09gvanrossumsetmessages: + msg390764
2021-04-11 02:17:09JelleZijlstrasetkeywords: + patch
nosy: + JelleZijlstra

pull_requests: + pull_request24074
stage: test needed -> patch review
2021-04-09 14:40:32kjsetnosy: + kj
2021-04-08 18:26:18gvanrossumsetmessages: + msg390540
2021-04-08 14:41:11xtreaksetnosy: + gvanrossum, levkivskyi
2021-04-08 11:09:29larrycreate