mirror of https://github.com/zulip/zulip.git
lint: Enforce consistent style of using transaction.atomic decorator.
When decorating a function, @transaction.atomic and @transaction.atomic() are equivalent. We can add a linting rule to enforce consistency.
This commit is contained in:
parent
bc3d03730f
commit
323f5dbba2
|
@ -21,7 +21,7 @@ def set_expiry_date_for_existing_confirmations(
|
|||
UNSUBSCRIBE = 4
|
||||
MULTIUSE_INVITE = 6
|
||||
|
||||
@transaction.atomic()
|
||||
@transaction.atomic
|
||||
def backfill_confirmations_between(lower_bound: int, upper_bound: int) -> None:
|
||||
confirmations = Confirmation.objects.filter(id__gte=lower_bound, id__lte=upper_bound)
|
||||
for confirmation in confirmations:
|
||||
|
|
|
@ -481,6 +481,10 @@ python_rules = RuleList(
|
|||
"pattern": "\\.(called(_once|_with|_once_with)?|not_called|has_calls|not_called)[(]",
|
||||
"description": 'A mock function is missing a leading "assert_"',
|
||||
},
|
||||
{
|
||||
"pattern": "@transaction.atomic\\(\\)",
|
||||
"description": "Use @transaction.atomic as function decorator for consistency.",
|
||||
},
|
||||
*whitespace_rules,
|
||||
],
|
||||
max_length=110,
|
||||
|
|
Loading…
Reference in New Issue