From 7649900948c8a65296ae6efc9d8ced0bc1a54a7f Mon Sep 17 00:00:00 2001 From: dosisod <39638017+dosisod@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:47:56 -0800 Subject: [PATCH] Use sets in `is_ignored_via_amend` --- refurb/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/refurb/main.py b/refurb/main.py index 40ff7f6..ade9dbf 100644 --- a/refurb/main.py +++ b/refurb/main.py @@ -104,20 +104,21 @@ def is_ignored_via_amend(error: Error, settings: Settings) -> bool: error_code = str(ErrorCode.from_error(type(error))) config_root = Path(settings.config_file).parent if settings.config_file else Path() - errors_to_ignore = [] - categories_to_ignore = [] + errors_to_ignore = set[str]() + categories_to_ignore = set[str]() + for ignore in settings.ignore: if ignore.path: ignore_path = (config_root / ignore.path).resolve() if path.is_relative_to(ignore_path): if isinstance(ignore, ErrorCode): - errors_to_ignore.append(str(ignore)) + errors_to_ignore.add(str(ignore)) else: - categories_to_ignore.append(ignore.value) + categories_to_ignore.add(ignore.value) - return error_code in errors_to_ignore or any( - category in categories_to_ignore for category in error.categories + return error_code in errors_to_ignore or bool( + categories_to_ignore.intersection(error.categories) )