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

[mypy] Finish type-hints addition to stmts.py module

parent 12785521915b
Pipeline #97236 passed with stages
in 2 minutes
......@@ -1106,10 +1106,10 @@ class Delete(Statement, ScopeNode):
return children
@property
def selection(self):
def selection(self) -> List["rql.nodes.VariableRef"]:
return [vref for et, vref in self.main_variables]
def add_main_variable(self, etype, vref):
def add_main_variable(self, etype: str, vref: "rql.nodes.VariableRef") -> None:
"""add a variable to the list of deleted variables"""
# if etype == 'Any':
# raise BadRQLQuery('"Any" is not supported in DELETE statement')
......@@ -1126,7 +1126,7 @@ class Delete(Statement, ScopeNode):
# repr / as_string / copy #################################################
def __repr__(self):
def __repr__(self) -> str:
result = ["DELETE"]
if self.main_variables:
result.append(
......@@ -1144,7 +1144,7 @@ class Delete(Statement, ScopeNode):
result.append("HAVING " + ",".join(repr(term) for term in self.having))
return " ".join(result)
def as_string(self, kwargs=None):
def as_string(self, kwargs: Optional[Dict] = None) -> str:
"""return the tree as an encoded rql string"""
result = ["DELETE"]
if self.main_variables:
......@@ -1168,7 +1168,9 @@ class Delete(Statement, ScopeNode):
)
return " ".join(result)
def copy(self):
# Signature of "copy" incompatible with supertype "ScopeNode" [override]
# Signature of "copy" incompatible with supertype "BaseNode" [override]
def copy(self) -> "rql.stmts.Delete": # type:ignore[override]
new = Delete()
for etype, var in self.main_variables:
vref = nodes.VariableRef(new.get_variable(var.name))
......@@ -1208,7 +1210,7 @@ class Insert(Statement, ScopeNode):
def selection(self):
return [vref for et, vref in self.main_variables]
def add_main_variable(self, etype, vref):
def add_main_variable(self, etype: str, vref: "rql.nodes.VariableRef") -> None:
"""add a variable to the list of inserted variables"""
if etype == "Any":
raise BadRQLQuery('"Any" is not supported in INSERT statement')
......@@ -1216,7 +1218,7 @@ class Insert(Statement, ScopeNode):
vref.parent = self
self.inserted_variables[vref.variable] = 1
def add_main_relation(self, relation):
def add_main_relation(self, relation: "rql.nodes.Relation") -> None:
"""add a relation to the list of inserted relations"""
var = relation.children[0].variable
rhs = relation.children[1]
......@@ -1230,7 +1232,7 @@ insertion variable"
# repr / as_string / copy #################################################
def __repr__(self):
def __repr__(self) -> str:
result = ["INSERT"]
result.append(
", ".join(["%r %r" % (etype, var) for etype, var in self.main_variables])
......@@ -1244,7 +1246,7 @@ insertion variable"
result.append("HAVING " + ",".join(repr(term) for term in self.having))
return " ".join(result)
def as_string(self, kwargs=None):
def as_string(self, kwargs: Optional[Any] = None) -> str:
"""return the tree as an encoded rql string"""
result = ["INSERT"]
result.append(
......@@ -1264,7 +1266,9 @@ insertion variable"
)
return " ".join(result)
def copy(self):
# Signature of "copy" incompatible with supertype "ScopeNode" [override]
# Signature of "copy" incompatible with supertype "BaseNode" [override]
def copy(self) -> "rql.stmts.Insert": # type:ignore[override]
new = Insert()
for etype, var in self.main_variables:
vref = nodes.VariableRef(new.get_variable(var.name))
......@@ -1301,14 +1305,14 @@ class Set(Statement, ScopeNode):
def selection(self):
return []
def add_main_relation(self, relation):
def add_main_relation(self, relation: "rql.nodes.Relation") -> None:
"""add a relation to the list of modified relations"""
relation.parent = self
self.main_relations.append(relation)
# repr / as_string / copy #################################################
def __repr__(self):
def __repr__(self) -> str:
result = ["SET"]
result.append(", ".join(repr(rel) for rel in self.main_relations))
if self.where is not None:
......@@ -1317,7 +1321,7 @@ class Set(Statement, ScopeNode):
result.append("HAVING " + ",".join(repr(term) for term in self.having))
return " ".join(result)
def as_string(self, kwargs=None):
def as_string(self, kwargs: Optional[Any] = None) -> str:
"""return the tree as an encoded rql string"""
result = ["SET"]
result.append(
......@@ -1332,7 +1336,9 @@ class Set(Statement, ScopeNode):
)
return " ".join(result)
def copy(self):
# Signature of "copy" incompatible with supertype "ScopeNode" [override]
# Signature of "copy" incompatible with supertype "BaseNode" [override]
def copy(self) -> "rql.stmts.Set": # type:ignore[override]
new = Set()
for child in self.main_relations:
new.add_main_relation(child.copy(new))
......
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