| 114 | 114 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | 115 | """Transforms a comma separated list of regular expressions.""" |
| 116 | 116 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 117 | if not value: | |
| 118 | return patterns | |
| 119 | ||
| 120 | # CSV parsing that handles quoted strings and escaped commas | |
| 121 | in_quote = False | |
| 122 | current_pattern = "" | |
| 123 | i = 0 | |
| 124 | while i < len(value): | |
| 125 | char = value[i] | |
| 126 | ||
| 127 | # Handle quoted strings | |
| 128 | if char == '"' and (i == 0 or value[i-1] != '\\'): | |
| 129 | in_quote = not in_quote | |
| 130 | # Handle escaped commas | |
| 131 | elif char == '\\' and i + 1 < len(value) and value[i+1] == ',': | |
| 132 | # Skip the backslash and include the comma | |
| 133 | current_pattern += ',' | |
| 134 | i += 1 # Skip the comma in the next iteration | |
| 135 | # Split on unescaped commas outside quotes | |
| 136 | elif char == ',' and not in_quote: | |
| 137 | stripped = current_pattern.strip() | |
| 138 | if stripped: | |
| 139 | patterns.append(_regex_transformer(stripped)) | |
| 140 | current_pattern = "" | |
| 141 | else: | |
| 142 | current_pattern += char | |
| 143 | i += 1 | |
| 144 | ||
| 145 | # Add the last pattern | |
| 146 | stripped = current_pattern.strip() | |
| 147 | if stripped: | |
| 148 | patterns.append(_regex_transformer(stripped)) | |
| 149 | ||
| 119 | 150 | return patterns |
| 120 | 151 | |
| 121 | 152 |
| Test Name | Status |
|---|---|
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.