Skip to content

Commit db97e60

Browse files
committed
fix(tags): import Self from typing for Python 3.11+
1 parent bc8479e commit db97e60

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

commitizen/tags.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from __future__ import annotations
22

33
import re
4+
import sys
45
import warnings
56
from collections.abc import Sequence
67
from dataclasses import dataclass, field
78
from functools import cached_property
89
from string import Template
910
from typing import TYPE_CHECKING, NamedTuple
1011

11-
from typing_extensions import Self
12-
1312
from commitizen import out
1413
from commitizen.defaults import DEFAULT_SETTINGS, Settings, get_tag_regexes
1514
from commitizen.git import GitTag
@@ -24,6 +23,12 @@
2423
if TYPE_CHECKING:
2524
from commitizen.version_schemes import VersionScheme
2625

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

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

0 commit comments

Comments
 (0)