mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Fix bytes type in autogenerated code confusing pylance
This commit is contained in:
parent
9ede5bd3c5
commit
6fd3eb2ee6
|
@ -97,6 +97,7 @@ def generate(fs: FakeFs, tl: ParsedTl) -> None:
|
||||||
writer.write("from typing import List, Optional, Self, Sequence")
|
writer.write("from typing import List, Optional, Self, Sequence")
|
||||||
writer.write("from .. import abcs")
|
writer.write("from .. import abcs")
|
||||||
writer.write("from ..core import Reader, Serializable, serialize_bytes_to")
|
writer.write("from ..core import Reader, Serializable, serialize_bytes_to")
|
||||||
|
writer.write("_bytes = bytes")
|
||||||
|
|
||||||
ns = f"{typedef.namespace[0]}." if typedef.namespace else ""
|
ns = f"{typedef.namespace[0]}." if typedef.namespace else ""
|
||||||
generated_type_names.add(f"{ns}{to_class_name(typedef.name)}")
|
generated_type_names.add(f"{ns}{to_class_name(typedef.name)}")
|
||||||
|
@ -162,6 +163,7 @@ def generate(fs: FakeFs, tl: ParsedTl) -> None:
|
||||||
writer.write("from typing import List, Optional, Self, Sequence")
|
writer.write("from typing import List, Optional, Self, Sequence")
|
||||||
writer.write("from .. import abcs")
|
writer.write("from .. import abcs")
|
||||||
writer.write("from ..core import Request, serialize_bytes_to")
|
writer.write("from ..core import Request, serialize_bytes_to")
|
||||||
|
writer.write("_bytes = bytes")
|
||||||
|
|
||||||
# def name(params, ...)
|
# def name(params, ...)
|
||||||
required_params = [p for p in functiondef.params if not is_computed(p.ty)]
|
required_params = [p for p in functiondef.params if not is_computed(p.ty)]
|
||||||
|
|
|
@ -65,7 +65,7 @@ _INNER_TYPE_MAP = {
|
||||||
"int128": "int",
|
"int128": "int",
|
||||||
"int256": "int",
|
"int256": "int",
|
||||||
"double": "float",
|
"double": "float",
|
||||||
"bytes": "bytes",
|
"bytes": "_bytes", # parameters called "bytes" confuse the global bytes type
|
||||||
"string": "str",
|
"string": "str",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def inner_type_fmt(ty: Type) -> str:
|
||||||
elif ty.bare:
|
elif ty.bare:
|
||||||
return to_class_name(ty.name)
|
return to_class_name(ty.name)
|
||||||
elif ty.generic_ref:
|
elif ty.generic_ref:
|
||||||
return "bytes"
|
return "_bytes"
|
||||||
elif ty.name == "Object":
|
elif ty.name == "Object":
|
||||||
return "Serializable"
|
return "Serializable"
|
||||||
else:
|
else:
|
||||||
|
@ -101,7 +101,7 @@ def param_type_fmt(ty: BaseParameter, *, immutable: bool) -> str:
|
||||||
else:
|
else:
|
||||||
inner_ty = ty.ty
|
inner_ty = ty.ty
|
||||||
|
|
||||||
res = "bytes" if inner_ty.name == "Object" else inner_type_fmt(inner_ty)
|
res = "_bytes" if inner_ty.name == "Object" else inner_type_fmt(inner_ty)
|
||||||
|
|
||||||
if ty.ty.generic_arg:
|
if ty.ty.generic_arg:
|
||||||
if immutable:
|
if immutable:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user