A real fix for issue #250 (failure with mock) (#295)
Fixes #250
The main idea here is optimizing generics for cases where a type information is added to existing code.
Now:
* ``Node[int]`` and ``Node`` have identical ``__bases__`` and identical ``__mro__[1:]`` (except for the first item, since it is the class itself).
* After addition of typing information (i.e. making some classes generic), ``__mro__`` is changed very little, at most one bare ``Generic`` appears in ``__mro__``.
* Consequently, only non-parameterized generics appear in ``__bases__`` and ``__mro__[1:]``.
Interestingly, this could be achieved in few lines of code and no existing test break.
On the positive side of this approach, there is very little chance that existing code (even with sophisticated "magic") will break after addition of typing information.
On the negative side, it will be more difficult for _runtime_ type-checkers to perform decorator-based type checks (e.g. enforce method overriding only by consistent methods). Essentially, now type erasure happens partially at the class creation time (all bases are reduced to origin).
(We have __orig_class__ and __orig_bases__ to help runtime checkers.)
4 files changed