uv

Finished
114114def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115115 """Transforms a comma separated list of regular expressions."""
116116 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
117 for pattern in _split_regex_csv(value):
118118 patterns.append(_regex_transformer(pattern))
119119 return patterns
120120
121121
122def _split_regex_csv(value: str) -> list[str]:
123 """Split a comma-separated list of regex patterns, respecting regex syntax.
124
125 This function handles commas within regex constructs like parentheses, brackets,
126 and braces, treating them as part of the regex rather than delimiters.
127 """
128 if not value:
129 return []
130
131 result: list[str] = []
132 current = ""
133 paren_count = 0 # Count of parentheses
134 bracket_count = 0 # Count of square brackets
135 brace_count = 0 # Count of curly braces
136 in_string = False # Whether we're inside a string
137 string_char = "" # The character used to start the string (' or ")
138 escape_next = False # Whether the next character is escaped
139
140 for char in value:
141 if escape_next:
142 current += char
143 escape_next = False
144 continue
145
146 if char == "\\":
147 current += char
148 escape_next = True
149 continue
150
151 # Handle string literals
152 if in_string:
153 if char == string_char:
154 in_string = False
155 string_char = ""
156 current += char
157 continue
158 elif char in "\"'":
159 in_string = True
160 string_char = char
161 current += char
162 continue
163
164 # Handle grouping constructs
165 if char == "(":
166 paren_count += 1
167 current += char
168 continue
169 elif char == ")":
170 if paren_count > 0:
171 paren_count -= 1
172 current += char
173 continue
174 elif char == "[":
175 bracket_count += 1
176 current += char
177 continue
178 elif char == "]":
179 if bracket_count > 0:
180 bracket_count -= 1
181 current += char
182 continue
183 elif char == "{":
184 brace_count += 1
185 current += char
186 continue
187 elif char == "}":
188 if brace_count > 0:
189 brace_count -= 1
190 current += char
191 continue
192
193 # Handle comma as delimiter only when not inside regex constructs
194 if char == "," and paren_count == 0 and bracket_count == 0 and brace_count == 0 and not in_string:
195 result.append(current.strip())
196 current = ""
197 continue
198
199 current += char
200
201 # Add the last pattern
202 if current or value.endswith(","):
203 result.append(current.strip())
204
205 # Filter out empty strings
206 return [pattern for pattern in result if pattern]
207
208
122209def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
123210 """Transforms a comma separated list of regular expressions paths."""
124211 patterns: list[Pattern[str]] = []
Test NameStatus
tests/config/test_config.py::test_csv_regex_error
Fail
tests/config/test_config.py::test_can_read_toml_env_variable
Pass
tests/config/test_config.py::test_unknown_message_id
Pass
tests/config/test_config.py::test_unknown_option_name
Pass
tests/config/test_config.py::test_unknown_short_option_name
Pass
tests/config/test_config.py::test_unknown_confidence
Pass
tests/config/test_config.py::test_empty_confidence
Pass
tests/config/test_config.py::test_unknown_yes_no
Pass
tests/config/test_config.py::test_unknown_py_version
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo-expected0]
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,bar-expected1]
Pass
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,
Pass
tests/config/test_config.py::test_regex_error
Pass
tests/config/test_config.py::test_short_verbose
Pass
tests/config/test_config.py::test_argument_separator
Pass
tests/config/test_config.py::test_clear_cache_post_run
Pass
tests/config/test_config.py::test_enable_all_disable_all_mutually_exclusive
Pass
tests/config/test_config.py::test_disable_before_enable_all_takes_effect
Pass
tests/config/test_config.py::test_enable_before_disable_all_takes_effect
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.