diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index e956085f..6c3dcb27 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -336,7 +336,8 @@ def start(format: bool = False): docstring=docstring, name=type, qualname=qualtype, - types=", ".join([f"raw.types.{c}" for c in constructors]) + types=", ".join([f"raw.types.{c}" for c in constructors]), + doc_name=snake(type).replace("_", "-") ) ) diff --git a/compiler/api/template/type.txt b/compiler/api/template/type.txt index 3d327282..99310359 100644 --- a/compiler/api/template/type.txt +++ b/compiler/api/template/type.txt @@ -15,3 +15,9 @@ class {name}: # type: ignore """ QUALNAME = "pyrogram.raw.base.{qualname}" + + def __init__(self): + raise TypeError("Base types can only be used for type checking purposes: " + "you tried to use a base type instance as argument, " + "but you need to instantiate one of its constructors instead. " + "More info: https://docs.pyrogram.org/telegram/base/{doc_name}")