Skip to content

Commit

Permalink
Fix DeprecationWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
kounelisagis committed Apr 17, 2024
1 parent f0aa919 commit 81bb63c
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tiledb/query_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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

0 comments on commit 81bb63c

Please sign in to comment.