| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | def _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 | Commas within regular expressions can be escaped with backslashes (\\,). | |
| 118 | """ | |
| 116 | 119 | patterns: list[Pattern[str]] = [] |
| 117 | for pattern in _csv_transformer(value): | |
| 118 | patterns.append(_regex_transformer(pattern)) | |
| 120 | # Handle escaped commas by temporarily replacing them | |
| 121 | # We replace \, with a placeholder, split on commas, then restore \, in each part | |
| 122 | temp_value = value.replace(r"\,", "\x00") # Use null byte as temporary placeholder | |
| 123 | raw_patterns = pylint_utils._splitstrip(temp_value) | |
| 124 | for pattern in raw_patterns: | |
| 125 | # Restore escaped commas | |
| 126 | final_pattern = pattern.replace("\x00", ",") | |
| 127 | patterns.append(_regex_transformer(final_pattern)) | |
| 119 | 128 | return patterns |
| 120 | 129 | |
| 121 | 130 | |
| 122 | 131 | def _regexp_paths_csv_transfomer(value: str) -> Sequence[Pattern[str]]: |
| 123 | """Transforms a comma separated list of regular expressions paths.""" | |
| 132 | """Transforms a comma separated list of regular expressions paths. | |
| 133 | ||
| 134 | Commas within regular expressions can be escaped with backslashes (\\,). | |
| 135 | """ | |
| 124 | 136 | patterns: list[Pattern[str]] = [] |
| 125 | for pattern in _csv_transformer(value): | |
| 137 | # Handle escaped commas by temporarily replacing them | |
| 138 | # We replace \, with a placeholder, split on commas, then restore \, in each part | |
| 139 | temp_value = value.replace(r"\,", "\x00") # Use null byte as temporary placeholder | |
| 140 | raw_patterns = pylint_utils._splitstrip(temp_value) | |
| 141 | for pattern in raw_patterns: | |
| 142 | # Restore escaped commas | |
| 143 | final_pattern = pattern.replace("\x00", ",") | |
| 126 | 144 | patterns.append( |
| 127 | 145 | re.compile( |
| 128 | str(pathlib.PureWindowsPath(pattern)).replace("\\", "\\\\") | |
| 146 | str(pathlib.PureWindowsPath(final_pattern)).replace("\\", "\\\\") | |
| 129 | 147 | + "|" |
| 130 | + pathlib.PureWindowsPath(pattern).as_posix() | |
| 148 | + pathlib.PureWindowsPath(final_pattern).as_posix() | |
| 131 | 149 | ) |
| 132 | 150 | ) |
| 133 | 151 | return patterns |
| 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.