alandtse / alandtse/tesla

Python 3.13 compatibility: KeyError 'home-page' in authcaptureproxy breaks import

オープン
#1,173 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る
stale triage
主要言語
Python
スター
780
フォーク
127
PR マージ指標
30日以内にマージされた PR はありません

説明

## Context
After updating Home Assistant to a version that runs on **Python 3.13**, the custom integrations **alexa_media** and **tesla_custom** fail to load due to an import-time exception in a shared dependency: **authcaptureproxy**.

This appears to be caused by stricter/different package metadata handling in Python 3.13 (via `importlib_metadata`). `authcaptureproxy` reads the distribution metadata and directly indexes the key `home-page`, which raises a `KeyError` when that field is missing.

## What happens
Home Assistant fails to import the integration stack because `authcaptureproxy` crashes at import time.

- **Error type:** `ImportError` caused by `KeyError: 'home-page'`
- **Affected file:** `/usr/local/lib/python3.13/site-packages/authcaptureproxy/__init__.py`
- **Line:** 31
- **Failing line:** `__uri__ = metadata["home-page"]`

## Traceback (excerpt)
```text
Python File "/usr/local/lib/python3.13/site-packages/alexapy/alexaproxy.py", line 15, in
import authcaptureproxy

File "/usr/local/lib/python3.13/site-packages/authcaptureproxy/__init__.py", line 31, in
__uri__ = metadata["home-page"]
~~~~~~~~^^^^^^^^^^^^^

File "/usr/local/lib/python3.13/site-packages/importlib_metadata/_adapters.py", line 102, in __getitem__
raise KeyError(item)

KeyError: 'home-page'
```

## Expected behavior
The integration should load on Python 3.13.

## Suggested fix
Make the metadata access in `authcaptureproxy/__init__.py` more robust, e.g.:

- Use a safe accessor: `metadata.get("home-page")` (or `metadata.get("Home-page")` depending on normalization)
- Fall back to other common fields such as `project-url` / `Project-URL` or `homepage` if present
- Or wrap in `try/except KeyError` and default `__uri__` to `None`/empty string

This would avoid a hard import-time crash when the metadata field is absent.

## Notes
This regression started immediately after moving to a Home Assistant release that uses **Python 3.13**, and affects multiple custom integrations because they share the same dependency.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。