|
3 | 3 | import os
|
4 | 4 | import re
|
5 | 5 | from collections import OrderedDict
|
| 6 | +from collections.abc import Iterable |
6 | 7 | from glob import iglob
|
7 | 8 | from logging import getLogger
|
8 | 9 | from string import Template
|
@@ -61,7 +62,7 @@ def find_increment(
|
61 | 62 | def update_version_in_files(
|
62 | 63 | current_version: str,
|
63 | 64 | new_version: str,
|
64 |
| - files: list[str], |
| 65 | + files: Iterable[str], |
65 | 66 | *,
|
66 | 67 | check_consistency: bool = False,
|
67 | 68 | encoding: str = ENCODING,
|
@@ -99,21 +100,22 @@ def update_version_in_files(
|
99 | 100 | return updated
|
100 | 101 |
|
101 | 102 |
|
102 |
| -def _files_and_regexes(patterns: list[str], version: str) -> list[tuple[str, str]]: |
| 103 | +def _files_and_regexes(patterns: Iterable[str], version: str) -> list[tuple[str, str]]: |
103 | 104 | """
|
104 | 105 | Resolve all distinct files with their regexp from a list of glob patterns with optional regexp
|
105 | 106 | """
|
106 |
| - out: list[tuple[str, str]] = [] |
| 107 | + out: set[tuple[str, str]] = set() |
107 | 108 | for pattern in patterns:
|
108 | 109 | drive, tail = os.path.splitdrive(pattern)
|
109 | 110 | path, _, regex = tail.partition(":")
|
110 | 111 | filepath = drive + path
|
111 | 112 | if not regex:
|
112 | 113 | regex = re.escape(version)
|
113 | 114 |
|
114 |
| - for path in iglob(filepath): |
115 |
| - out.append((path, regex)) |
116 |
| - return sorted(list(set(out))) |
| 115 | + for file in iglob(filepath): |
| 116 | + out.add((file, regex)) |
| 117 | + |
| 118 | + return sorted(out) |
117 | 119 |
|
118 | 120 |
|
119 | 121 | def _bump_with_regex(
|
|
0 commit comments