Add Device Detection Support
まだ誰も着手していません。
評価
調査の方向性
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 35/100
fastly/compute-sdk-python#74 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
fastly/compute-sdk-python#61 ·
-
fastly/compute-sdk-python#60 · 担当者 1 名 ·
fastly/compute-sdk-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/skills#1811 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
speaches-ai/speaches#678 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
datalayer/mcp-compose#42 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conda-forge/spacy-feedstock#177 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
UKGovernmentBEIS/inspect_evals#2523 ·