From 81bb63c2c1767e5db582e7b1bbb00599d0fa7422 Mon Sep 17 00:00:00 2001 From: Agis Kounelis Date: Wed, 17 Apr 2024 03:12:17 +0300 Subject: [PATCH] Fix DeprecationWarning --- tiledb/query_condition.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tiledb/query_condition.py b/tiledb/query_condition.py index 163e29b54a..7f71c02cf9 100644 --- a/tiledb/query_condition.py +++ b/tiledb/query_condition.py @@ -15,9 +15,7 @@ filtering query results on attribute and dimension values. """ -QueryConditionNodeElem = Union[ - ast.Name, ast.Constant, ast.Call, ast.Num, ast.Str, ast.Bytes -] +QueryConditionNodeElem = Union[ast.Name, ast.Constant, ast.Call] @dataclass @@ -280,8 +278,8 @@ def is_variable_node(self, variable: QueryConditionNodeElem) -> bool: return ( isinstance(variable.args[0], ast.Constant) - or isinstance(variable.args[0], ast.Str) - or isinstance(variable.args[0], ast.Bytes) + or isinstance(variable.args[0], ast.Constant) + or isinstance(variable.args[0], ast.Constant) ) return isinstance(variable, ast.Name) @@ -326,7 +324,9 @@ def get_variable_from_node(self, node: QueryConditionNodeElem) -> Any: variable = variable_node.id elif isinstance(variable_node, ast.Constant): variable = variable_node.value - elif isinstance(variable_node, ast.Str) or isinstance(variable_node, ast.Bytes): + elif isinstance(variable_node, ast.Constant) or isinstance( + variable_node, ast.Constant + ): # deprecated in 3.8 variable = variable_node.s else: @@ -363,13 +363,15 @@ def get_value_from_node(self, node: QueryConditionNodeElem) -> Any: if isinstance(value_node, ast.Constant): value = value_node.value - elif isinstance(value_node, ast.NameConstant): + elif isinstance(value_node, ast.Constant): # deprecated in 3.8 value = value_node.value - elif isinstance(value_node, ast.Num): + elif isinstance(value_node, ast.Constant): # deprecated in 3.8 value = value_node.n - elif isinstance(value_node, ast.Str) or isinstance(value_node, ast.Bytes): + elif isinstance(value_node, ast.Constant) or isinstance( + value_node, ast.Constant + ): # deprecated in 3.8 value = value_node.s else: @@ -491,7 +493,7 @@ def visit_UnaryOp(self, node: ast.UnaryOp, sign: int = 1): else: if isinstance(node.operand, ast.Constant): node.operand.value *= sign - elif isinstance(node.operand, ast.Num): + elif isinstance(node.operand, ast.Constant): node.operand.n *= sign else: raise TileDBError( @@ -500,18 +502,18 @@ def visit_UnaryOp(self, node: ast.UnaryOp, sign: int = 1): return node.operand - def visit_Num(self, node: ast.Num) -> ast.Num: + def visit_Num(self, node: ast.Constant) -> ast.Constant: # deprecated in 3.8 return node - def visit_Str(self, node: ast.Str) -> ast.Str: + def visit_Str(self, node: ast.Constant) -> ast.Constant: # deprecated in 3.8 return node - def visit_Bytes(self, node: ast.Bytes) -> ast.Bytes: + def visit_Bytes(self, node: ast.Constant) -> ast.Constant: # deprecated in 3.8 return node - def visit_NameConstant(self, node: ast.NameConstant) -> ast.NameConstant: + def visit_NameConstant(self, node: ast.Constant) -> ast.Constant: # deprecated in 3.8 return node