| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | """Transforms a comma separated list of regular expressions.""" | |
| 115 | """Transforms a comma separated list of regular expressions. | |
| 116 | ||
| 117 | Commas within regex patterns can be escaped with backslash (\,). | |
| 118 | For example: (foo{1\,3}),bar.* will be parsed as two patterns: | |
| 119 | - (foo{1,3}) | |
| 120 | - bar.* | |
| 121 | """ | |
| 116 | 122 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 123 | ||
| 124 | # Custom CSV parser that handles escaped commas | |
| 125 | current_pattern = [] | |
| 126 | i = 0 | |
| 127 | while i < len(value): | |
| 128 | if value[i] == '\\' and i + 1 < len(value) and value[i + 1] == ',': | |
| 129 | # Escaped comma, add literal comma to current pattern | |
| 130 | current_pattern.append(',') | |
| 131 | i += 2 # Skip both backslash and comma | |
| 132 | elif value[i] == ',': | |
| 133 | # Unescaped comma, end current pattern | |
| 134 | pattern_str = ''.join(current_pattern).strip() | |
| 135 | if pattern_str: # Only add non-empty patterns | |
| 136 | patterns.append(_regex_transformer(pattern_str)) | |
| 137 | current_pattern = [] | |
| 138 | i += 1 | |
| 139 | else: | |
| 140 | # Regular character, add to current pattern | |
| 141 | current_pattern.append(value[i]) | |
| 142 | i += 1 | |
| 143 | ||
| 144 | # Add the last pattern if there is one | |
| 145 | pattern_str = ''.join(current_pattern).strip() | |
| 146 | if pattern_str: | |
| 147 | patterns.append(_regex_transformer(pattern_str)) | |
| 148 | ||
| 119 | 149 | return patterns |
| 120 | 150 | |
| 121 | 151 |
| Test Name | Status |
|---|---|
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.