| 113 | 113 | |
| 114 | 114 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | 115 | """Transforms a comma separated list of regular expressions.""" |
| 116 | patterns: list[Pattern[str]] = [] | |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 119 | return patterns | |
| 116 | # First try to treat the entire value as a single regex pattern | |
| 117 | try: | |
| 118 | single_pattern = [_regex_transformer(value)] | |
| 119 | # If it contains commas, also try splitting to see if it's multiple patterns | |
| 120 | if ',' in value: | |
| 121 | try: | |
| 122 | patterns: list[Pattern[str]] = [] | |
| 123 | for pattern in _csv_transformer(value): | |
| 124 | patterns.append(_regex_transformer(pattern)) | |
| 125 | # If splitting works and gives multiple patterns, use that | |
| 126 | if len(patterns) > 1: | |
| 127 | return patterns | |
| 128 | except argparse.ArgumentTypeError: | |
| 129 | # Splitting failed, so use the single pattern | |
| 130 | pass | |
| 131 | return single_pattern | |
| 132 | except argparse.ArgumentTypeError: | |
| 133 | # If that fails, treat it as a comma-separated list of patterns | |
| 134 | patterns: list[Pattern[str]] = [] | |
| 135 | for pattern in _csv_transformer(value): | |
| 136 | patterns.append(_regex_transformer(pattern)) | |
| 137 | return patterns | |
| 120 | 138 | |
| 121 | 139 | |
| 122 | 140 | def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 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.