Is there a reason that Generic.__new__ does not pass *args and **kwargs to the super class's __new__? These are required in some cases for proper behavior.
Here's a somewhat non-sensical example that demonstrates the problem:
from __future__ import absolute_import, print_function
from typing import Generic, TypeVar
T = TypeVar('T')
class BaseThing(Generic[T]):
def __new__(cls, *args, **kwargs):
kwargs.setdefault('encoding', 'utf-8')
return super(BaseThing, cls).__new__(cls, *args, **kwargs)
class Str(BaseThing, unicode):
pass
s = Str('blarg')
print(repr(s))
s is u'' instead of u'blarg'.
The offending code is in the typing._generic_new() helper.
Is there a reason that
Generic.__new__does not pass*argsand**kwargsto the super class's__new__? These are required in some cases for proper behavior.Here's a somewhat non-sensical example that demonstrates the problem:
sisu''instead ofu'blarg'.The offending code is in the
typing._generic_new()helper.