mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
custom_check: Add rule to avoid creating savepoints.
This commit adds a custom rule to check python files and raise lint error if they have transaction.atomic used without any argument or savepoint=True is used. It helps to avoid creating unintended savepoints in the future.
This commit is contained in:
committed by
Tim Abbott
parent
62b3e49075
commit
c5b3d2e434
@@ -462,8 +462,23 @@ python_rules = RuleList(
|
||||
"description": 'A mock function is missing a leading "assert_"',
|
||||
},
|
||||
{
|
||||
"pattern": "@transaction.atomic\\(\\)",
|
||||
"description": "Use @transaction.atomic as function decorator for consistency.",
|
||||
"pattern": r"transaction\.atomic$|transaction\.atomic\(\)|savepoint=True",
|
||||
"description": "Use 'durable=True' or 'savepoint=False' argument explicitly to avoid the possibility of creating savepoints.",
|
||||
"exclude": {"confirmation/migrations/", "zerver/migrations/", "zilencer/migrations/"},
|
||||
"exclude_line": {
|
||||
(
|
||||
"zerver/actions/create_user.py",
|
||||
"with suppress(IntegrityError), transaction.atomic(savepoint=True):",
|
||||
),
|
||||
(
|
||||
"zerver/lib/test_classes.py",
|
||||
"with transaction.atomic(savepoint=True):",
|
||||
),
|
||||
(
|
||||
"zerver/tests/test_subs.py",
|
||||
"with transaction.atomic(savepoint=True), self.assertRaises(JsonableError):",
|
||||
),
|
||||
},
|
||||
},
|
||||
*whitespace_rules,
|
||||
*shebang_rules,
|
||||
|
Reference in New Issue
Block a user