Skip to content

Commit 79dd19d

Browse files
authored
fix(tags): fixes ImportError on Python >=3.11 (#1363) (#1364)
1 parent bc8479e commit 79dd19d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

commitizen/tags.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from string import Template
99
from typing import TYPE_CHECKING, NamedTuple
1010

11-
from typing_extensions import Self
12-
1311
from commitizen import out
1412
from commitizen.defaults import DEFAULT_SETTINGS, Settings, get_tag_regexes
1513
from commitizen.git import GitTag
@@ -22,8 +20,16 @@
2220
)
2321

2422
if TYPE_CHECKING:
23+
import sys
24+
2525
from commitizen.version_schemes import VersionScheme
2626

27+
# Self is Python 3.11+ but backported in typing-extensions
28+
if sys.version_info < (3, 11):
29+
from typing_extensions import Self
30+
else:
31+
from typing import Self
32+
2733

2834
class VersionTag(NamedTuple):
2935
"""Represent a version and its matching tag form."""

0 commit comments

Comments
 (0)