| 111 | 111 | raise argparse.ArgumentTypeError(msg) from e |
| 112 | 112 | |
| 113 | 113 | |
| 114 | def _csv_transformer_with_quotes(value: str) -> Sequence[str]: | |
| 115 | """Transforms a comma separated string, handling quoted strings properly.""" | |
| 116 | if not value: | |
| 117 | return [] | |
| 118 | ||
| 119 | result = [] | |
| 120 | current = "" | |
| 121 | in_quotes = False | |
| 122 | i = 0 | |
| 123 | ||
| 124 | while i < len(value): | |
| 125 | char = value[i] | |
| 126 | ||
| 127 | if char == '"' and (i == 0 or value[i-1] != '\\'): | |
| 128 | # Toggle quote state | |
| 129 | in_quotes = not in_quotes | |
| 130 | elif char == ',' and not in_quotes: | |
| 131 | # End of current field | |
| 132 | result.append(current.strip()) | |
| 133 | current = "" | |
| 134 | else: | |
| 135 | current += char | |
| 136 | ||
| 137 | i += 1 | |
| 138 | ||
| 139 | # Add the last field | |
| 140 | result.append(current.strip()) | |
| 141 | ||
| 142 | # Remove empty fields | |
| 143 | return [field for field in result if field != ""] | |
| 144 | ||
| 145 | ||
| 114 | 146 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | 147 | """Transforms a comma separated list of regular expressions.""" |
| 116 | 148 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 149 | for pattern in _csv_transformer_with_quotes(value): | |
| 118 | 150 | patterns.append(_regex_transformer(pattern)) |
| 119 | 151 | return patterns |
| 120 | 152 | |
| 122 | 154 | def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 123 | 155 | """Transforms a comma separated list of regular expressions paths.""" |
| 124 | 156 | patterns: list[Pattern[str]] = [] |
| 125 | for pattern in _csv_transformer(value): | |
| 157 | for pattern in _csv_transformer_with_quotes(value): | |
| 126 | 158 | patterns.append( |
| 127 | 159 | re.compile( |
| 128 | 160 | str(pathlib.PureWindowsPath(pattern)).replace("\\", "\\\\") |
| 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.