code-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

code-review

代码审核

Review code changes following pplx-sdk project standards and the layered architecture.
对照pplx-sdk项目标准及分层架构审核代码变更。

When to use

使用场景

Use this skill when reviewing pull requests or code changes in the pplx-sdk repository to ensure compliance with project conventions.
当在pplx-sdk仓库中审核拉取请求或代码变更时,使用此技能以确保符合项目规范。

Instructions

操作步骤

  1. Check architecture layer compliance: Verify imports respect
    core → shared → transport/domain → client
    dependency flow. No circular imports allowed.
  2. Verify type safety: All functions must have complete type annotations. Use
    from __future__ import annotations
    at the top of every module.
  3. Validate error handling: Custom exceptions from
    pplx_sdk.core.exceptions
    must be used — never bare
    Exception
    . Chain exceptions with
    from exc
    .
  4. Review docstrings: Google-style docstrings required on all public classes and methods, including Args, Returns, Raises sections.
  5. Check test coverage: Tests follow Arrange-Act-Assert pattern with descriptive names (
    test_<module>_<behavior>
    ).
  6. Inspect Pydantic models: Domain models use Pydantic v2
    BaseModel
    with
    Field()
    descriptions.
  7. Verify transport protocol: Transport implementations conform to the
    Transport
    protocol from
    pplx_sdk.core.protocols
    .
  1. 检查架构层合规性:验证导入是否遵循
    core → shared → transport/domain → client
    的依赖流向。不允许循环导入。
  2. 验证类型安全性:所有函数必须具备完整的类型注解。在每个模块顶部使用
    from __future__ import annotations
  3. 验证错误处理:必须使用
    pplx_sdk.core.exceptions
    中的自定义异常——禁止使用原生
    Exception
    。通过
    from exc
    链接异常。
  4. 审核文档字符串:所有公共类和方法必须使用Google风格的文档字符串,包含Args、Returns、Raises章节。
  5. 检查测试覆盖率:测试需遵循Arrange-Act-Assert模式,且测试名称具有描述性(格式为
    test_<module>_<behavior>
    )。
  6. 检查Pydantic模型:领域模型使用Pydantic v2的
    BaseModel
    并搭配
    Field()
    描述。
  7. 验证传输协议:传输实现需符合
    pplx_sdk.core.protocols
    中的
    Transport
    协议。

Architecture Layer Rules

架构层规则

core/        → No imports from other pplx_sdk modules
shared/      → May import from core/ only
transport/   → May import from core/, shared/
domain/      → May import from core/, shared/, transport/
client.py    → May import from all layers
core/        → 禁止导入其他pplx_sdk模块
shared/      → 仅可从core/导入
transport/   → 可从core/、shared/导入
domain/      → 可从core/、shared/、transport/导入
client.py    → 可从所有层导入

Exception Hierarchy

异常层级

PerplexitySDKError (base)
├── TransportError (status_code, response_body)
│   ├── AuthenticationError (401)
│   └── RateLimitError (429, retry_after)
├── StreamingError
└── ValidationError
PerplexitySDKError (基类)
├── TransportError (status_code, response_body)
│   ├── AuthenticationError (401)
│   └── RateLimitError (429, retry_after)
├── StreamingError
└── ValidationError

Output Format

输出格式

For each file reviewed, provide:
  • ✅ Passes — or
  • ❌ Issue found: description and suggested fix
对于每个审核的文件,提供:
  • ✅ 通过 —— 或
  • ❌ 发现问题:描述及建议修复方案