from typing import TYPE_CHECKING, Any, ParamSpec, Self, TypeVar, cast
from urllib.parse import urlparse
-import cchardet as chardet
+import chardet
import ifaddr
from zeroconf import IPVersion
if TYPE_CHECKING:
from collections.abc import Iterator
+ from chardet.resultdict import ResultDict
from zeroconf.asyncio import AsyncServiceInfo
from music_assistant.mass import MusicAssistant
async def detect_charset(data: bytes, fallback: str = "utf-8") -> str:
"""Detect charset of raw data."""
try:
- detected: dict[str, Any] = await asyncio.to_thread(chardet.detect, data)
+ detected: ResultDict = await asyncio.to_thread(chardet.detect, data)
if detected and detected["encoding"] and detected["confidence"] > 0.75:
assert isinstance(detected["encoding"], str) # for type checking
return detected["encoding"]
"certifi==2025.4.26",
"colorlog==6.9.0",
"cryptography==44.0.3",
- "faust-cchardet>=2.1.18",
+ "chardet>=5.2.0",
"ifaddr==0.2.0",
"mashumaro==3.15",
"music-assistant-frontend==2.15.1",