Skip to content

fix: 修复非 Linux 平台下 libc 未定义 NameError 及规范类型注解 - #82

Open
reginaldalfret wants to merge 1 commit into
vivo:mainfrom
reginaldalfret:fix/detect-platform-name-error-and-typing
Open

reginaldalfret wants to merge 1 commit into
vivo:mainfrom
reginaldalfret:fix/detect-platform-name-error-and-typing

Conversation

@reginaldalfret

Copy link
Copy Markdown

概述

本 PR 修复了在非 Linux 环境(如 macOS)下 detect_platform 抛出 NameError: name 'libc' is not defined 的问题,并规范了配置流程中的类型注解。

改动说明

  1. 修复 detect_platform 中未定义变量问题 (py_vhome/vhome.py)

    • 原代码中 else 分支直接返回 (sysplat, arch, libc),但在非 Linux/非 Windows 环境下 libc 未被定义,导致直接触发 NameError。
    • 现调整为返回 (sysplat, arch, None),保持与类型签名 Tuple[str, str, Optional[str]] 一致。
  2. 修复类型注解语法 (config_flow.py & device_manager.py)

    • 修正 description_placeholders: {} = {} 为 description_placeholders: dict[str, Any] = {}。
  3. 优化 async_unload_entry 调用结构 (__init__.py)

    • 提取 dm = DeviceManager.instance(),避免冗余连续链式调用 .instance().instance()。

…typing annotations

In py_vhome/vhome.py, return None for libc when the host platform is not Linux, avoiding NameError on macOS and other platforms. In config_flow.py and device_manager.py, replace invalid type annotations with dict[str, Any]. In __init__.py, simplify chained DeviceManager.instance() calls.

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant