bohdan

Finished
111111 raise argparse.ArgumentTypeError(msg) from e
112112
113113
114def _regexp_csv_parser(value: str) -> list[str]:
115 """Parse a comma-separated list of values, respecting quoted strings and regex syntax.
116
117 This function handles quoted strings and regex constructs that may contain commas,
118 allowing regex patterns with commas (like quantifiers {1,3}) to be properly parsed.
119 """
120 if not value:
121 return []
122
123 result = []
124 current = ""
125 in_quotes = False
126 quote_char = None
127 paren_depth = 0
128 bracket_depth = 0
129 brace_depth = 0
130 i = 0
131
132 while i < len(value):
133 char = value[i]
134
135 # Handle quotes
136 if char in "'"":
137 if not in_quotes:
138 # Starting a quoted string
139 in_quotes = True
140 quote_char = char
141 elif quote_char == char:
142 # Ending a quoted string
143 in_quotes = False
144 quote_char = None
145 else:
146 # Quote character inside a different quote type
147 current += char
148 # Handle parentheses, brackets, and braces
149 elif char == '(' and not in_quotes:
150 paren_depth += 1
151 current += char
152 elif char == ')' and not in_quotes:
153 if paren_depth > 0:
154 paren_depth -= 1
155 current += char
156 elif char == '[' and not in_quotes:
157 bracket_depth += 1
158 current += char
159 elif char == ']' and not in_quotes:
160 if bracket_depth > 0:
161 bracket_depth -= 1
162 current += char
163 elif char == '{' and not in_quotes:
164 brace_depth += 1
165 current += char
166 elif char == '}' and not in_quotes:
167 if brace_depth > 0:
168 brace_depth -= 1
169 current += char
170 # Handle comma separator only when not inside quotes or regex constructs
171 elif char == "," and not in_quotes and paren_depth == 0 and bracket_depth == 0 and brace_depth == 0:
172 # Comma outside quotes and regex constructs is a separator
173 result.append(current.strip())
174 current = ""
175 else:
176 current += char
177
178 i += 1
179
180 # Add the last item
181 if current or value.endswith(","):
182 result.append(current.strip())
183
184 # Filter out empty strings
185 return [item for item in result if item]
186
187
114188def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115189 """Transforms a comma separated list of regular expressions."""
116190 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
191 for pattern in _regexp_csv_parser(value):
118192 patterns.append(_regex_transformer(pattern))
119193 return patterns
120194
122196def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
123197 """Transforms a comma separated list of regular expressions paths."""
124198 patterns: list[Pattern[str]] = []
125 for pattern in _csv_transformer(value):
199 for pattern in _regexp_csv_parser(value):
126200 patterns.append(
127201 re.compile(
128202 str(pathlib.PureWindowsPath(pattern)).replace("\\", "\\\\")
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.