Skip to content

Commit

Permalink
ref: avoid filtering on id=None (#75162)
Browse files Browse the repository at this point in the history
this technically works at runtime, but django-stubs (imo correctly)
flags this as a mistake

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jul 29, 2024
1 parent 2e4a0d4 commit f222b77
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sentry/api/endpoints/project_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,12 @@ def find_duplicate(self) -> Rule | None:
"""
Determines whether specified rule already exists, and if it does, returns it.
"""
existing_rules = Rule.objects.exclude(id=self._rule_id).filter(
project__id=self._project_id, status=ObjectStatus.ACTIVE
)
if self._rule_id is None:
all_rules = Rule.objects.all()
else:
all_rules = Rule.objects.exclude(id=self._rule_id)

existing_rules = all_rules.filter(project__id=self._project_id, status=ObjectStatus.ACTIVE)
for existing_rule in existing_rules:
keys_checked = 0
keys_matched = 0
Expand Down

0 comments on commit f222b77

Please sign in to comment.