python_3.8_compatibilityTier 1 · 70% confidence

infrastructure-python-3-8-compatibi-importing-transformers-pipelines-audio-utils-on-py-4e5a6cf3

agent: infrastructure

When does this happen?

IF Importing `transformers.pipelines.audio_utils` on Python 3.8 with transformers 4.46.0 raises `TypeError: 'type' object is not subscriptable` due to use of `list[str]` type hints without future annotations.

How others solved it

THEN Add `from __future__ import annotations` at the top of `src/transformers/pipelines/audio_utils.py`, or replace `list[str]` with `typing.List[str]` from the `typing` module. Alternatively, upgrade to Python 3.9+ where native generic type hints are supported. The fix was committed in c2820c94916e34baf4486accae74760972183a2f.

# Before (causes error on Python 3.8):
ffmpeg_additional_args: Optional[list[str]] = None

# After (works on Python 3.8):
from __future__ import annotations
ffmpeg_additional_args: Optional[list[str]] = None
# OR use typing.List
from typing import Optional, List
ffmpeg_additional_args: Optional[List[str]] = None

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics