| 113 | 113 | |
| 114 | 114 | def _regexp_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 115 | 115 | """Transforms a comma separated list of regular expressions.""" |
| 116 | # Check if the entire value is quoted - if so, treat as single pattern | |
| 117 | # This allows users to explicitly specify regex patterns with commas | |
| 118 | original_value = value | |
| 119 | unquoted_value = pylint_utils._unquote(value) | |
| 120 | if unquoted_value != original_value: | |
| 121 | # The value was quoted, so treat it as a single pattern | |
| 122 | return [_regex_transformer(unquoted_value)] | |
| 123 | ||
| 124 | # Otherwise, use the previous logic for backward compatibility | |
| 116 | 125 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 119 | return patterns | |
| 126 | split_patterns = _csv_transformer(value) | |
| 127 | ||
| 128 | # If we have multiple patterns after splitting, try to compile each one | |
| 129 | if len(split_patterns) > 1: | |
| 130 | try: | |
| 131 | compiled_patterns = [] | |
| 132 | for pattern in split_patterns: | |
| 133 | # Unquote each individual pattern too | |
| 134 | unquoted_pattern = pylint_utils._unquote(pattern) | |
| 135 | compiled_patterns.append(_regex_transformer(unquoted_pattern)) | |
| 136 | return compiled_patterns | |
| 137 | except argparse.ArgumentTypeError: | |
| 138 | # If any pattern fails to compile, fall through to try as single pattern | |
| 139 | pass | |
| 140 | ||
| 141 | # If we have a single pattern or comma-separated compilation failed, | |
| 142 | # try to treat the entire value as a single regex pattern | |
| 143 | try: | |
| 144 | patterns.append(_regex_transformer(unquoted_value)) | |
| 145 | return patterns | |
| 146 | except argparse.ArgumentTypeError: | |
| 147 | # If that also fails, re-raise the error | |
| 148 | raise | |
| 120 | 149 | |
| 121 | 150 | |
| 122 | 151 | 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.