Skip to content

Commit

Permalink
Prepend bases on first subscription (#386)
Browse files Browse the repository at this point in the history
* Prepend bases with _gorg on subscription

* Simplify code
  • Loading branch information
ilevkivskyi authored Feb 3, 2017
1 parent d149ce7 commit 1229efb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions python2/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def test_basics(self):
Y[unicode]
with self.assertRaises(TypeError):
Y[unicode, unicode]
self.assertIsSubclass(SimpleMapping[str, int], SimpleMapping)

def test_generic_errors(self):
T = TypeVar('T')
Expand Down
4 changes: 3 additions & 1 deletion python2/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,10 @@ def __getitem__(self, params):
_check_generic(self, params)
tvars = _type_vars(params)
args = params

prepend = (self,) if self.__origin__ is None else ()
return self.__class__(self.__name__,
self.__bases__,
prepend + self.__bases__,
dict(self.__dict__),
tvars=tvars,
args=args,
Expand Down
1 change: 1 addition & 0 deletions src/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def test_basics(self):
Y[str]
with self.assertRaises(TypeError):
Y[str, str]
self.assertIsSubclass(SimpleMapping[str, int], SimpleMapping)

def test_generic_errors(self):
T = TypeVar('T')
Expand Down
4 changes: 3 additions & 1 deletion src/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,10 @@ def __getitem__(self, params):
_check_generic(self, params)
tvars = _type_vars(params)
args = params

prepend = (self,) if self.__origin__ is None else ()
return self.__class__(self.__name__,
self.__bases__,
prepend + self.__bases__,
_no_slots_copy(self.__dict__),
tvars=tvars,
args=args,
Expand Down

0 comments on commit 1229efb

Please sign in to comment.