8000 Follow up for #283 (response to comments) including change in Union[X, Any] by ilevkivskyi · Pull Request #288 · python/typing · GitHub
[go: up one dir, main page]

Skip to content

Follow up for #283 (response to comments) including change in Union[X, Any] #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Response to comments
  • Loading branch information
ilevkivskyi committed Sep 29, 2016
commit c5b66dea9ca1ac98f5d7b73c7230252f7cc5d354
7 changes: 7 additions & 0 deletions python2/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def test_subclass_error(self):
def test_union_any(self):
u = Union[Any]
self.assertEqual(u, Any)
u1 = Union[int, Any]
u2 = Union[Any, int]
u3 = Union[Any, object]
self.assertEqual(u1, u2)
self.assertNotEqual(u1, Any)
self.assertNotEqual(u2, Any)
self.assertNotEqual(u3, Any)

def test_union_object(self):
u = Union[object]
Expand Down
4 changes: 4 additions & 0 deletions python2/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ class Manager(Employee): pass
Union[Manager, int, Employee] == Union[int, Employee]
Union[Employee, Manager] == Employee

- Similar for object::

Union[int, object] == object

- You cannot subclass or instantiate a union.

- You cannot write Union[X][Y] (what would it mean?).
Expand Down
7 changes: 7 additions & 0 deletions src/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ def test_subclass_error(self):
def test_union_any(self):
u = Union[Any]
self.assertEqual(u, Any)
u1 = Union[int, Any]
u2 = Union[Any, int]
u3 = Union[Any, object]
self.assertEqual(u1, u2)
self.assertNotEqual(u1, Any)
self.assertNotEqual(u2, Any)
self.assertNotEqual(u3, Any)

def test_union_object(self):
u = Union[object]
Expand Down
4 changes: 4 additions & 0 deletions src/typing.py
4E53
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ class Manager(Employee): pass
Union[Manager, int, Employee] == Union[int, Employee]
Union[Employee, Manager] == Employee

- Similar for object::

Union[int, object] == object

- You cannot subclass or instantiate a union.

- You cannot write Union[X][Y] (what would it mean?).
Expand Down
0