harrison

Finished
112112
113113
114114def _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 For patterns containing commas and curly braces (like {1,3}), tries to compile
118 as a single regex first. If that fails or if there are no curly braces,
119 splits on commas and compiles each part separately.
120 This allows regex patterns with quantifiers to work without escaping,
121 while maintaining backward compatibility for comma-separated lists.
122 """
116123 patterns: list[Pattern[str]] = []
124
125 # Handle empty string
126 if not value.strip():
127 return patterns
128
129 # If the string contains commas and curly braces, try as single regex first
130 if "," in value and "{" in value and "}" in value:
131 try:
132 patterns.append(_regex_transformer(value.strip()))
133 return patterns
134 except (argparse.ArgumentTypeError, re.error):
135 # Fall back to splitting
136 pass
137
138 # Default behavior: split on commas and compile each part
117139 for pattern in _csv_transformer(value):
118 patterns.append(_regex_transformer(pattern))
140 if pattern.strip(): # Skip empty patterns
141 patterns.append(_regex_transformer(pattern))
142
119143 return patterns
120144
121145
Test NameStatus
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.