mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Make .to_dict() work on invalid TLObjects
This will improve logging from the previous commit as well.
This commit is contained in:
parent
d3efc8f57d
commit
f25541ea6f
|
@ -54,7 +54,11 @@ def _write_modules(
|
|||
SourceBuilder(f) as builder:
|
||||
builder.writeln(AUTO_GEN_NOTICE)
|
||||
|
||||
builder.writeln('from {}.tl.tlobject import {}', '.' * depth, kind)
|
||||
builder.writeln('from {}.tl.tlobject import TLObject', '.' * depth)
|
||||
if kind != 'TLObject':
|
||||
builder.writeln(
|
||||
'from {}.tl.tlobject import {}', '.' * depth, kind)
|
||||
|
||||
builder.writeln('from typing import Optional, List, '
|
||||
'Union, TYPE_CHECKING')
|
||||
|
||||
|
@ -296,13 +300,14 @@ def _write_to_dict(tlobject, builder):
|
|||
else:
|
||||
if arg.is_vector:
|
||||
builder.write(
|
||||
'[] if self.{0} is None else [None '
|
||||
'if x is None else x.to_dict() for x in self.{0}]',
|
||||
'[] if self.{0} is None else [x.to_dict() '
|
||||
'if isinstance(x, TLObject) else x for x in self.{0}]',
|
||||
arg.name
|
||||
)
|
||||
else:
|
||||
builder.write(
|
||||
'None if self.{0} is None else self.{0}.to_dict()',
|
||||
'self.{0}.to_dict() '
|
||||
'if isinstance(self.{0}, TLObject) else self.{0}',
|
||||
arg.name
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user