Skip to content

Commit 22d9077

Browse files
committed
Warn users in case they try to use base types as arguments
1 parent 4dd0686 commit 22d9077

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/api/compiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ def start(format: bool = False):
336336
docstring=docstring,
337337
name=type,
338338
qualname=qualtype,
339-
types=", ".join([f"raw.types.{c}" for c in constructors])
339+
types=", ".join([f"raw.types.{c}" for c in constructors]),
340+
doc_name=snake(type).replace("_", "-")
340341
)
341342
)
342343

compiler/api/template/type.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ class {name}: # type: ignore
1515
"""
1616

1717
QUALNAME = "pyrogram.raw.base.{qualname}"
18+
19+
def __init__(self):
20+
raise TypeError("Base types can only be used for type checking purposes: "
21+
"you tried to use a base type instance as argument, "
22+
"but you need to instantiate one of its constructors instead. "
23+
"More info: https://docs.pyrogram.org/telegram/base/{doc_name}")

0 commit comments

Comments
 (0)