简体中文 English 繁體中文 日本語 Русский
本文为静态镜像,内容以交互版为准 在交互式文档中心打开 →

Type Stub Generation (IDE Completion)

ErisPulse dynamically discovers modules/adapters via entry-points, and the entry points cannot statically know the specific types of user classes.
The epsdk types command scans installed modules/adapters to generate a type stub file, allowing users to use these types as variable annotations to obtain IDE completion.

Core Design Principles

Stub files export only types and provide no runtime instances:

Basic Usage

Run the following command in the project root directory:

epsdk types

This will generate _ep_types.py in the current directory, containing types for all installed modules/adapters.

Using in Code

from _ep_types import MyModule, Yunhu
from ErisPulse import sdk

# By using the imported types as variable annotations, IDE will provide completion for the class's methods
my_mod: MyModule = sdk.module.get("MyModule")
my_mod.hello()                  # ← IDE completes hello

my_adapter: Yunhu = sdk.adapter.get("yunhu")
await my_adapter.Send.To("group", "123").Board(...)   # ← Completes platform-specific methods

How It Works

  1. Scan erispulse.adapter / erispulse.module entry-points
  2. Inspect each adapter/module's actual class information (including module path and qualified name) within the target Python environment via a subprocess
  3. Generate a .py file, where:
    • All from xxx import Yyy as Zzz statements are included under TYPE_CHECKING
    • Zzz is the PascalCase form of the entry-point name
  4. The IDE reads the TYPE_CHECKING section to provide code completion; no code is executed at runtime

Example of generated stubs:

# _ep_types.py (auto-generated)
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    # Adapters
    from MyAdapter.Core import MyAdapter as MyAdapter
    from YunhuAdapter.Core import YunhuAdapter as Yunhu

    # Modules
    from MyModule.Core import Main as MyModule

    __all__ = ['MyAdapter', 'Yunhu', 'MyModule']

Command Options

Option Description
-o, --output PATH Specify the output file path (default: ./_ep_types.py)
--force Overwrite existing stub files
--adapters-only Scan only adapters
--modules-only Scan only modules

When to Regenerate

Relationship with SendDSL Standard Methods

The SendDSL base class already has built-in standard sending methods (Text/Image/Voice/Video/File), and any instance of SendDSL obtained through any method can complete these methods.
The types command is mainly used to complete platform-specific methods (such as Board for Yunhu, Dice for Sandbox) and module-specific methods.