From 6137b7b995b6ea0bd4e4195c5693d2312fa26639 Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Sat, 18 Nov 2023 15:03:37 +0000 Subject: [PATCH] update is_precedent() annotation to accept against=None This is commonly passed in already by `.self_group()` calls where `against` defaults to `None`. Handle `against is None` explicitly as the standard type stubs only accepts the key type for the second argument to `dict.get()`. --- lib/sqlalchemy/sql/operators.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index 6402d0fd1b..1d3f2f483f 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -2582,9 +2582,13 @@ _PRECEDENCE: Dict[OperatorType, int] = { } -def is_precedent(operator: OperatorType, against: OperatorType) -> bool: +def is_precedent( + operator: OperatorType, against: Optional[OperatorType] +) -> bool: if operator is against and is_natural_self_precedent(operator): return False + elif against is None: + return True else: return bool( _PRECEDENCE.get( -- 2.47.3