Skip to content

Commit

Permalink
Use sets in is_ignored_via_amend
Browse files Browse the repository at this point in the history
  • Loading branch information
dosisod committed Nov 21, 2024
1 parent 9b1a609 commit 7649900
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions refurb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)


Expand Down

0 comments on commit 7649900

Please sign in to comment.