Skip to content

Commit 7d0abd5

Browse files
authored
Only import typing_extensions if necessary (#2232)
Fixes #2231.
1 parent f01ea64 commit 7d0abd5

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fix URL joining in Python client (#2228)
88
- Handle anyOf/allOf in JSON transforms (#2237)
99
- Fix redefining a named Avro type in a diamond dependency pattern (#2238)
10+
- Fix typing_extensions import errors on Python 3.12 (#2232)
1011

1112

1213
## v2.14.0 - 2026-04-01

src/confluent_kafka/aio/_AIOConsumer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import concurrent.futures
1717
from typing import Any, Callable, Dict, Optional, Tuple
1818

19-
# FIXME: import from typing once we depend on Python >= 3.11
20-
from typing_extensions import Self
19+
try:
20+
from typing import Self
21+
except ImportError:
22+
# FIXME: drop fallback once we require Python >= 3.11
23+
from typing_extensions import Self
2124

2225
import confluent_kafka
2326

src/confluent_kafka/aio/producer/_AIOProducer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
import logging
1818
from typing import Any, Callable, Dict, Optional
1919

20-
# FIXME: import from typing once we depend on Python >= 3.11
21-
from typing_extensions import Self
20+
try:
21+
from typing import Self
22+
except ImportError:
23+
# FIXME: drop fallback once we require Python >= 3.11
24+
from typing_extensions import Self
2225

2326
import confluent_kafka
2427

src/confluent_kafka/cimpl.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ maintenance burden and get type hints directly from the implementation.
3535
"""
3636

3737
import builtins
38-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload
38+
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, overload
3939

40-
from typing_extensions import Literal, Self
40+
try:
41+
from typing import Self
42+
except ImportError:
43+
# FIXME: drop fallback once we require Python >= 3.11
44+
from typing_extensions import Self
4145

4246
from confluent_kafka.admin._metadata import ClusterMetadata, GroupMetadata
4347

0 commit comments

Comments
 (0)