Commit e1b50ead authored by Nsukami Patrick's avatar Nsukami Patrick
Browse files

[mypy]: Improve type hints for stmts.py module

- remove even more useless comments
- remove even more useless casts
parent 59c3d01fe012
......@@ -354,9 +354,8 @@ class Union(Statement, Node):
def tr(msg, context=None):
return msg
# "BaseNode" has no attribute "get_description"
return [
c.get_description(mainindex, tr) # type: ignore[attr-defined]
c.get_description(mainindex, tr)
for c in self.children
]
......@@ -374,8 +373,6 @@ class Union(Statement, Node):
return strings[0]
return " UNION ".join("(%s)" % part for part in strings)
# Signature of "copy" incompatible with supertype "Node"
# Signature of "copy" incompatible with supertype "BaseNode"
def copy(
self, stmt: Optional["rql.stmts.Statement"] = None, copy_children: bool = True
) -> "rql.stmts.Union":
......@@ -394,9 +391,7 @@ class Union(Statement, Node):
def get_variable_variables(self) -> Set_[int]:
change: Set_[int] = set()
for idx in self.get_variable_indices():
# "BaseNode" has no attribute "selection"
# is the first children always a Select?
first_child = cast("rql.stmts.Select", self.children[0])
first_child = self.children[0]
vrefs = first_child.selection[idx].iget_nodes(nodes.VariableRef)
for vref in vrefs:
......@@ -410,9 +405,6 @@ class Union(Statement, Node):
change: Set_[int] = set()
values: Dict[int, Set_] = {}
for select in self.children:
# "BaseNode" has no attribute "get_selection_solutions"
# get_selection_solutions only defined inside Select class
select = cast("rql.stmts.Select", select)
for descr in select.get_selection_solutions():
for i, etype in enumerate(descr):
values.setdefault(i, set()).add(etype)
......@@ -424,14 +416,12 @@ class Union(Statement, Node):
def _locate_subquery(
self, col: int, etype: str, kwargs: Optional[Dict[Any, Any]] = None
) -> Tuple:
# "BaseNode" has no attribute "with_" [attr-defined]
first_child = cast("rql.stmts.Select", self.children[0])
first_child = self.children[0]
has_children = len(self.children) == 1
first_child_subqueries = not first_child.with_
if has_children and first_child_subqueries:
return self.children[0], col
for select in self.children:
select = cast("rql.stmts.Select", select)
term = select.selection[col]
try:
if term.name in select.aliases:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment