agent

Finished
111111 raise argparse.ArgumentTypeError(msg) from e
112112
113113
114def _should_treat_as_single_pattern(value: str) -> bool:
115 """Determine if a string should be treated as a single regex pattern.
116
117 This heuristic checks if the string contains regex syntax that commonly
118 uses commas, suggesting it's meant to be a single pattern rather than
119 multiple patterns separated by commas.
120
121 Args:
122 value: The string to check
123
124 Returns:
125 True if the string should be treated as a single pattern
126 """
127 # Check for regex quantifiers with commas like {m,n}
128 if '{' in value and ',' in value and '}' in value:
129 # Look for patterns like {m,n} or {m,n,}
130 if re.search(r'\{[^}]*,[^}]*\}', value):
131 return True
132
133 # Check for character classes with ranges like [a-z,A-Z]
134 if '[' in value and ',' in value and ']' in value:
135 # Look for patterns like [a-z,A-Z] or similar
136 if re.search(r'\[[^\]]*,[^\]]*\]', value):
137 return True
138
139 return False
140
114141def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]:
115 """Transforms a comma separated list of regular expressions."""
142 """Transforms a comma separated list of regular expressions.
143
144 This function intelligently handles regex patterns that contain commas.
145 It uses a heuristic to determine if the string should be treated as a
146 single pattern (when it contains regex syntax with commas) or split
147 into multiple patterns.
148 """
116149 patterns: list[Pattern[str]] = []
150
151 # Check if this looks like a single pattern with regex syntax using commas
152 if _should_treat_as_single_pattern(value):
153 # Treat as a single pattern
154 patterns.append(_regex_transformer(value))
155 return patterns
156
157 # Fall back to CSV splitting for multiple simple patterns
117158 for pattern in _csv_transformer(value):
118159 patterns.append(_regex_transformer(pattern))
119160 return patterns
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.