[New-bugs-announce] [issue43772] Minor repr error in typing.TypeVar.__ror__()
Larry Hastings
report at bugs.python.org
Thu Apr 8 07:09:29 EDT 2021
New submission from Larry Hastings <larry at hastings.org>:
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.
----------
components: Library (Lib)
messages: 390524
nosy: larry
priority: low
severity: normal
stage: test needed
status: open
title: Minor repr error in typing.TypeVar.__ror__()
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43772>
_______________________________________
More information about the New-bugs-announce
mailing list