From db4bfadb7bb7bbcd81fffbc3f9f2ca45c101523e Mon Sep 17 00:00:00 2001 From: "Caleb P. Burns" <2126043+cpburnz@users.noreply.github.com> Date: Tue, 6 Jan 2026 08:11:06 -0500 Subject: [PATCH 1/3] Update ignore.py Support pathspec v1 --- dvc/ignore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dvc/ignore.py b/dvc/ignore.py index f74191eace..8a14fcb48c 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -5,7 +5,7 @@ from itertools import chain, groupby, takewhile from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Optional, Union, overload -from pathspec.patterns import GitWildMatchPattern +from pathspec.patterns.gitignore.spec import GitIgnoreSpecPattern from pathspec.util import normalize_file from pygtrie import Trie @@ -34,7 +34,7 @@ class DvcIgnorePatterns(DvcIgnore): def __init__( self, pattern_list: Iterable[Union[PatternInfo, str]], dirname: str, sep: str ) -> None: - from pathspec.patterns.gitwildmatch import _DIR_MARK + from pathspec.patterns.gitignore.spec import _DIR_MARK pattern_infos = [ pattern if isinstance(pattern, PatternInfo) else PatternInfo(pattern, "") @@ -48,7 +48,7 @@ def __init__( regex_pattern_list: list[tuple[str, bool, bool, PatternInfo]] = [] for count, pattern_info in enumerate(pattern_infos): - regex, ignore = GitWildMatchPattern.pattern_to_regex(pattern_info.patterns) + regex, ignore = GitIgnoreSpecPattern.pattern_to_regex(pattern_info.patterns) if regex is not None and ignore is not None: self.pattern_list.append(pattern_info) regex = regex.replace(f"<{_DIR_MARK}>", f"<{_DIR_MARK}{count}>") From 74704b71438cd7a6f1616506eabf1fbe4dac9938 Mon Sep 17 00:00:00 2001 From: Caleb Burns <2126043+cpburnz@users.noreply.github.com> Date: Tue, 6 Jan 2026 08:52:08 -0500 Subject: [PATCH 2/3] Update pyproject.toml Support pathspec v1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9912539d46..ea02f43348 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ dependencies = [ "networkx>=2.5", "omegaconf", "packaging>=19", - "pathspec>=0.10.3,<1", + "pathspec>=1.0.1,<2", "platformdirs<5,>=3.1.1", "psutil>=5.8", "pydot>=1.2.4", From af8e58ce652f10121405d725f7247fc978f4f591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Sat, 31 Jan 2026 10:55:56 +0545 Subject: [PATCH 3/3] keep compat with pathspec<1 --- dvc/ignore.py | 19 +++++++++++++++++-- pyproject.toml | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dvc/ignore.py b/dvc/ignore.py index 8a14fcb48c..7bd679e1ba 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -5,7 +5,15 @@ from itertools import chain, groupby, takewhile from typing import TYPE_CHECKING, Any, Literal, NamedTuple, Optional, Union, overload -from pathspec.patterns.gitignore.spec import GitIgnoreSpecPattern +try: + from pathspec.patterns.gitignore.spec import ( # type: ignore[import-not-found] + GitIgnoreSpecPattern, + ) +except ImportError: # pathspec<1 + from pathspec.patterns import ( + GitWildMatchPattern as GitIgnoreSpecPattern, + ) + from pathspec.util import normalize_file from pygtrie import Trie @@ -34,7 +42,14 @@ class DvcIgnorePatterns(DvcIgnore): def __init__( self, pattern_list: Iterable[Union[PatternInfo, str]], dirname: str, sep: str ) -> None: - from pathspec.patterns.gitignore.spec import _DIR_MARK + try: + from pathspec.patterns.gitignore.spec import ( # type: ignore[import-not-found] + _DIR_MARK, + ) + except ImportError: # pathspec<1 + from pathspec.patterns.gitwildmatch import ( # type: ignore[attr-defined, no-redef] + _DIR_MARK, + ) pattern_infos = [ pattern if isinstance(pattern, PatternInfo) else PatternInfo(pattern, "") diff --git a/pyproject.toml b/pyproject.toml index ea02f43348..e107235483 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ dependencies = [ "networkx>=2.5", "omegaconf", "packaging>=19", - "pathspec>=1.0.1,<2", + "pathspec>=0.10.3,<2", "platformdirs<5,>=3.1.1", "psutil>=5.8", "pydot>=1.2.4",