| 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 | # Check if the value contains regex syntax that suggests it's a single pattern | |
| 117 | regex_syntax_chars = set("{[()]}*+?.^$|\\") | |
| 118 | has_regex_syntax = any(char in value for char in regex_syntax_chars) | |
| 119 | ||
| 120 | # If it has regex syntax, try to compile the entire value as a single pattern | |
| 121 | if has_regex_syntax: | |
| 122 | try: | |
| 123 | return [_regex_transformer(value)] | |
| 124 | except (argparse.ArgumentTypeError, re.error): | |
| 125 | # # If that fails, fall back to comma-separated parsing | |
| 126 | pass | |
| 127 | ||
| 128 | # Try comma-separated parsing | |
| 129 | csv_patterns = _csv_transformer(value) | |
| 130 | if len(csv_patterns) > 1: | |
| 131 | # Try to compile all patterns | |
| 132 | try: | |
| 133 | patterns: list[Pattern[str]] = [] | |
| 134 | for pattern in csv_patterns: | |
| 135 | patterns.append(_regex_transformer(pattern)) | |
| 136 | return patterns | |
| 137 | except (argparse.ArgumentTypeError, re.error): | |
| 138 | # If any pattern fails to compile, treat the whole value as a single pattern | |
| 139 | pass | |
| 140 | ||
| 141 | # Treat the entire value as a single regex pattern | |
| 142 | return [_regex_transformer(value)] | |
| 120 | 143 | |
| 121 | 144 | |
| 122 | 145 | 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.