Skip to content

Commit c5b66de

Browse files
committed
Response to comments
1 parent 2d6f3dd commit c5b66de

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

python2/test_typing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def test_subclass_error(self):
201201
def test_union_any(self):
202202
u = Union[Any]
203203
self.assertEqual(u, Any)
204+
u1 = Union[int, Any]
205+
u2 = Union[Any, int]
206+
u3 = Union[Any, object]
207+
self.assertEqual(u1, u2)
208+
self.assertNotEqual(u1, Any)
209+
self.assertNotEqual(u2, Any)
210+
self.assertNotEqual(u3, Any)
204211

205212
def test_union_object(self):
206213
u = Union[object]

python2/typing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,10 @@ class Manager(Employee): pass
606606
Union[Manager, int, Employee] == Union[int, Employee]
607607
Union[Employee, Manager] == Employee
608608
609+
- Similar for object::
610+
611+
Union[int, object] == object
612+
609613
- You cannot subclass or instantiate a union.
610614
611615
- You cannot write Union[X][Y] (what would it mean?).

src/test_typing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ def test_subclass_error(self):
202202
def test_union_any(self):
203203
u = Union[Any]
204204
self.assertEqual(u, Any)
205+
u1 = Union[int, Any]
206+
u2 = Union[Any, int]
207+
u3 = Union[Any, object]
208+
self.assertEqual(u1, u2)
209+
self.assertNotEqual(u1, Any)
210+
self.assertNotEqual(u2, Any)
211+
self.assertNotEqual(u3, Any)
205212

206213
def test_union_object(self):
207214
u = Union[object]

src/typing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@ class Manager(Employee): pass
549549
Union[Manager, int, Employee] == Union[int, Employee]
550550
Union[Employee, Manager] == Employee
551551
552+
- Similar for object::
553+
554+
Union[int, object] == object
555+
552556
- You cannot subclass or instantiate a union.
553557
554558
- You cannot write Union[X][Y] (what would it mean?).

0 commit comments

Comments
 (0)