Skip to content

Commit 7865e9f

Browse files
committed
Fix #70 incompatibility
1 parent 9adbcd2 commit 7865e9f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pathspec/gitignore.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Callable,
99
Collection,
1010
Iterable,
11-
TYPE_CHECKING,
11+
Type,
1212
TypeVar,
1313
Union)
1414

@@ -23,7 +23,11 @@
2323
from .util import (
2424
_is_iterable)
2525

26-
Self = TypeVar("Self")
26+
Self = TypeVar("Self", bound="GitIgnoreSpec")
27+
"""
28+
:class:`GitIgnoreSpec` self type hint to support Python v<3.11 using PEP
29+
673 recommendation.
30+
"""
2731

2832

2933
class GitIgnoreSpec(PathSpec):
@@ -47,7 +51,7 @@ def __eq__(self, other: object) -> bool:
4751

4852
@classmethod
4953
def from_lines(
50-
cls: type[Self],
54+
cls: Type[Self],
5155
lines: Iterable[AnyStr],
5256
pattern_factory: Union[str, Callable[[AnyStr], Pattern], None] = None,
5357
) -> Self:

pathspec/pathspec.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Iterable,
1717
Iterator,
1818
Optional,
19-
TYPE_CHECKING,
19+
Type,
2020
TypeVar,
2121
Union)
2222

@@ -30,7 +30,11 @@
3030
match_file,
3131
normalize_file)
3232

33-
Self = TypeVar("Self")
33+
Self = TypeVar("Self", bound="PathSpec")
34+
"""
35+
:class:`PathSpec` self type hint to support Python v<3.11 using PEP 673
36+
recommendation.
37+
"""
3438

3539

3640
class PathSpec(object):
@@ -94,7 +98,7 @@ def __iadd__(self: Self, other: "PathSpec") -> Self:
9498

9599
@classmethod
96100
def from_lines(
97-
cls: type[Self],
101+
cls: Type[Self],
98102
pattern_factory: Union[str, Callable[[AnyStr], Pattern]],
99103
lines: Iterable[AnyStr],
100104
) -> Self:

0 commit comments

Comments
 (0)