agent

Finished
111111 raise argparse.ArgumentTypeError(msg) from e
112112
113113
114def _smart_csv_split(value: str) -> Sequence[str]:
115 """Split a comma-separated string while respecting quoted strings and escaped commas.
116
117 Commas inside single or double quotes are preserved, as are escaped commas (\,).
118 This allows regex patterns containing commas to be properly parsed.
119
120 Examples:
121 _smart_csv_split('pattern1,pattern2') -> ['pattern1', 'pattern2']
122 _smart_csv_split('(foo{1,3})') -> ['(foo{1,3})']
123 _smart_csv_split('"pattern,with,commas",pattern2') -> ['pattern,with,commas', 'pattern2']
124 _smart_csv_split('pattern1\\,pattern2') -> ['pattern1,pattern2']
125 """
126 if not value:
127 return []
128
129 result: list[str] = []
130 current = []
131 in_quotes = False
132 quote_char = None
133 escape_next = False
134
135 for char in value:
136 if escape_next:
137 # Previous character was a backslash, so include this character literally
138 current.append(char)
139 escape_next = False
140 elif char == '\\':
141 # Next character should be escaped
142 escape_next = True
143 elif char in ('"', "'") and (not in_quotes or char == quote_char):
144 # Toggle quote state
145 if in_quotes:
146 in_quotes = False
147 quote_char = None
148 else:
149 in_quotes = True
150 quote_char = char
151 current.append(char)
152 elif char == ',' and not in_quotes and not escape_next:
153 # End of field
154 field = ''.join(current).strip()
155 if field:
156 result.append(field)
157 current = []
158 else:
159 current.append(char)
160
161 # Handle last character
162 if current:
163 field = ''.join(current).strip()
164 result.append(field)
165
166 return result
167
168
169
114170def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115 """Transforms a comma separated list of regular expressions."""
171 """Transforms a comma separated list of regular expressions.
172
173 This function intelligently handles regex patterns containing commas.
174 If the string contains regex quantifier syntax like {n,m}, it is treated
175 as a single pattern. Otherwise, it falls back to comma splitting for
176 backward compatibility.
177 """
178 # If the string contains regex quantifier syntax, treat it as a single pattern
179 if re.search(r'\{\d+,\d+\}', value):
180 pattern = _regex_transformer(value)
181 return [pattern]
182
183 # Otherwise, fall back to comma splitting
116184 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
118 patterns.append(_regex_transformer(pattern))
185 for pattern_str in _smart_csv_split(value):
186 patterns.append(_regex_transformer(pattern_str))
119187 return patterns
120188
121189
122190def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
123 """Transforms a comma separated list of regular expressions paths."""
191 """Transforms a comma separated list of regular expressions paths.
192
193 This function intelligently handles regex patterns containing commas.
194 If the string contains regex quantifier syntax like {n,m}, it is treated
195 as a single pattern. Otherwise, it falls back to comma splitting for
196 backward compatibility.
197 """
198 # If the string contains regex quantifier syntax, treat it as a single pattern
199 if re.search(r'\{\d+,\d+\}', value):
200 pattern = re.compile(
201 str(pathlib.PureWindowsPath(value)).replace("\\", "\\\\")
202 + "|"
203 + pathlib.PureWindowsPath(value).as_posix()
204 )
205 return [pattern]
206
207 # Otherwise, fall back to comma splitting
124208 patterns: list[Pattern[str]] = []
125 for pattern in _csv_transformer(value):
209 for pattern_str in _smart_csv_split(value):
126210 patterns.append(
127211 re.compile(
128 str(pathlib.PureWindowsPath(pattern)).replace("\\", "\\\\")
212 str(pathlib.PureWindowsPath(pattern_str)).replace("\\", "\\\\")
129213 + "|"
130 + pathlib.PureWindowsPath(pattern).as_posix()
214 + pathlib.PureWindowsPath(pattern_str).as_posix()
131215 )
132216 )
133217 return patterns
Test NameStatus
tests/config/test_config.py::test_csv_regex_error
Fail
tests/config/test_config.py::test_can_read_toml_env_variable
Fail
tests/config/test_config.py::test_unknown_message_id
Fail
tests/config/test_config.py::test_unknown_option_name
Fail
tests/config/test_config.py::test_unknown_short_option_name
Fail
tests/config/test_config.py::test_unknown_confidence
Fail
tests/config/test_config.py::test_empty_confidence
Fail
tests/config/test_config.py::test_unknown_yes_no
Fail
tests/config/test_config.py::test_unknown_py_version
Fail
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo-expected0]
Fail
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,bar-expected1]
Fail
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,
Fail
tests/config/test_config.py::test_regex_error
Fail
tests/config/test_config.py::test_short_verbose
Fail
tests/config/test_config.py::test_argument_separator
Fail
tests/config/test_config.py::test_clear_cache_post_run
Fail
tests/config/test_config.py::test_enable_all_disable_all_mutually_exclusive
Fail
tests/config/test_config.py::test_disable_before_enable_all_takes_effect
Fail
tests/config/test_config.py::test_enable_before_disable_all_takes_effect
Fail

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