Add Device Detection Support
还没有人认领这个 Issue。
评估
调研方向
从 stubs/wit_world/imports/device_detection.py 中的 WIT bindings 开始,检查 Viceroy 的 device-detection 实现,以确定可用的测试响应。添加基于函数的 lookup API 和带有向前兼容未知字段的 DeviceInfo dataclass,然后使用合成响应或适当的 xfail 用例测试解析、错误处理以及未匹配的 lookup。
由索引模型根据 Issue 内容生成。
描述
Overview
Add support for Fastly's Device Detection API, which provides device capabilities and characteristics based on User-Agent strings.
WIT Interface
interface device-detection {
use types.{error};
/// Returns JSON-encoded device data for a User-Agent string
lookup: func(user-agent: string, max-len: u64) -> result<option<string>, error>;
}
WIT bindings: stubs/wit_world/imports/device_detection.py
API Design
- Simple function-based API:
lookup(user_agent: str) -> Optional[DeviceInfo] - Parse JSON response into
@dataclasswith_extrafield for forward compatibility - Return
Nonefor lookups that don't match any known device - Fields typically include:
is_mobile,is_desktop,is_tablet,is_bot,device_type,brand,model, etc.
Forward Compatibility: Use @dataclass with _extra: dict field to capture unknown fields (same pattern as Geo). Provides type hints for known fields while allowing future fields to be accessible.
Cross-SDK Comparison: All SDKs expose simple lookup(user_agent) returning parsed JSON. Rust returns DeviceInfo struct, Go returns *DeviceDetection, JS returns object. All have similar field structure (device type, name, vendor, etc.).
Viceroy Testing
Device detection support in Viceroy is limited or stubbed. The WIT interface exists but may not have full test data support via test.toml configuration like other features.
Tests should either:
- Use
xfailmarkers for functionality that requires production device detection data - Mock the User-Agent lookup if Viceroy provides stub/default responses
- Focus on API wrapper behavior (parsing, error handling) with synthetic responses
Check Viceroy's device detection implementation to determine exact testing capabilities.
Reference
- 主要语言
- Python
- 星标
- 5
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fastly/compute-sdk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
fastly/compute-sdk-python#116 ·
-
难度 4/5 3-5 天 新手友好度 35/100
fastly/compute-sdk-python#98 ·
-
难度 5/5 一周以上 新手友好度 35/100
fastly/compute-sdk-python#74 ·
-
难度 5/5 一周以上 新手友好度 35/100
fastly/compute-sdk-python#61 ·
-
Set up Sphinx Documentation Infrastructure可能重新可做 @erikrose 于 171 天前认领,目前没有进行中的 PR。 未关闭
fastly/compute-sdk-python#60 · 已指派 1 人 ·
查看 fastly/compute-sdk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
solana-foundation/pay-kit#341 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nasa/python_cmr#123 ·
-
难度 1/5 1 小时以内 新手友好度 92/100
EleutherAI/lm-evaluation-harness#4243 ·
维护者通常 1 天内回复
-
area: dashboard bug perceived difficulty: 3
难度 2/5 1-3 小时 新手友好度 88/100
Nitjsefnie-Harness-Commons/daedalus#1179 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
cusp-ai-oss/tojax#17 ·