xas

Finished
111111 raise argparse.ArgumentTypeError(msg) from e
112112
113113
114def _split_regex_csv(value: str) -> Sequence[str]:
115 """Split a CSV string while respecting escaped commas.
116
117 Commas can be escaped with backslashes. The backslashes will be removed
118 from the resulting patterns.
119
120 Examples:
121 "pattern1,pattern2" -> ["pattern1", "pattern2"]
122 "pattern1\\,withcomma,pattern2" -> ["pattern1,withcomma", "pattern2"]
123 "(foo{1\\,3})" -> ["(foo{1,3})"]
124 """
125 if not value:
126 return []
127
128 result: list[str] = []
129 current: list[str] = []
130 i = 0
131
132 while i < len(value):
133 char = value[i]
134 if char == '\\' and i + 1 < len(value) and value[i + 1] == ',':
135 # Escaped comma - add the comma without the backslash
136 current.append(',')
137 i += 2 # Skip both backslash and comma
138 elif char == ',':
139 # Unescaped comma - end of current pattern
140 pattern = ''.join(current).strip()
141 if pattern: # Only add non-empty patterns
142 result.append(pattern)
143 current = []
144 i += 1
145 else:
146 current.append(char)
147 i += 1
148
149 # Add the last pattern
150 pattern = ''.join(current).strip()
151 if pattern:
152 result.append(pattern)
153
154 return result
155
156
114157def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115 """Transforms a comma separated list of regular expressions."""
158 """Transforms a comma separated list of regular expressions.
159
160 Commas within regex patterns can be escaped with backslashes.
161 For example: "(foo{1\\,3}),bar" will be parsed as two patterns:
162 "(foo{1,3})" and "bar".
163 """
116164 patterns: list[Pattern[str]] = []
117 for pattern in _csv_transformer(value):
165 for pattern in _split_regex_csv(value):
118166 patterns.append(_regex_transformer(pattern))
119167 return patterns
120168
Test NameStatus
tests/config/test_config.py::test_csv_regex_error
Fail
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,
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_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.