mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-22 00:56:37 +03:00
Fix python 3.6 namedtuple compatibility
This commit is contained in:
parent
8a581f27db
commit
355b8c7321
|
@ -10,11 +10,9 @@ def namedtuple(*args, **kwargs):
|
|||
:return: namedtuple class
|
||||
"""
|
||||
if sys.version_info < (3, 7):
|
||||
defaults = kwargs.pop('defaults', {})
|
||||
defaults = kwargs.pop('defaults', ())
|
||||
TupleClass = basenamedtuple(*args, **kwargs)
|
||||
TupleClass.__new__.__defaults__ = (None,) * len(TupleClass._fields)
|
||||
prototype = TupleClass(*defaults)
|
||||
TupleClass.__new__.__defaults__ = tuple(prototype)
|
||||
TupleClass.__new__.__defaults__ = (None,) * (len(TupleClass._fields) - len(defaults)) + tuple(defaults)
|
||||
return TupleClass
|
||||
else:
|
||||
return basenamedtuple(*args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user