mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140348: Fix using | on unusual objects plus Unions (#140383)
This commit is contained in:
parent
248ce9fa8c
commit
7a9437d986
3 changed files with 28 additions and 1 deletions
|
|
@ -2283,6 +2283,15 @@ class Ints(enum.IntEnum):
|
|||
self.assertEqual(Union[Literal[1], Literal[Ints.B], Literal[True]].__args__,
|
||||
(Literal[1], Literal[Ints.B], Literal[True]))
|
||||
|
||||
def test_allow_non_types_in_or(self):
|
||||
# gh-140348: Test that using | with a Union object allows things that are
|
||||
# not allowed by is_unionable().
|
||||
U1 = Union[int, str]
|
||||
self.assertEqual(U1 | float, Union[int, str, float])
|
||||
self.assertEqual(U1 | "float", Union[int, str, "float"])
|
||||
self.assertEqual(float | U1, Union[float, int, str])
|
||||
self.assertEqual("float" | U1, Union["float", int, str])
|
||||
|
||||
|
||||
class TupleTests(BaseTestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue