Commit deafcbc7 authored by Frank Bessou's avatar Frank Bessou 🍁
Browse files

feat: move Solution and SolutionsList type aliases to stmts.py

parent 5d07f86bf4b1
......@@ -38,9 +38,6 @@ from typing_extensions import Protocol
__docformat__ = "restructuredtext en"
Solution = Dict[str, str]
SolutionsList = List[Solution]
# this is a node of the syntax tree
# used, for now, for Select.vargraph
Graph = Union_[Dict[Tuple[str, str], str], Dict[str, List[str]], Dict]
......
......@@ -51,6 +51,9 @@ __docformat__: str = "restructuredtext en"
if TYPE_CHECKING:
import rql
Solution = Dict[str, str]
SolutionsList = List[Solution]
def _check_references(
defined: Dict[str, Union_["rql.nodes.Variable", "rql.nodes.ColumnAlias"]],
......@@ -86,7 +89,7 @@ class ScopeNode(BaseNode):
self.defined_vars: Dict[str, "rql.nodes.Variable"] = {}
self.with_: List["rql.nodes.SubQuery"] = []
# list of possibles solutions for used variables
self.solutions: rt.SolutionsList = []
self.solutions: SolutionsList = []
self._varmaker = None # variable names generator, built when necessary
self.where: Optional["rql.base.Node"] = None # where clause node
self.having: Iterable["rql.base.Node"] = () # XXX now a single node
......@@ -134,7 +137,7 @@ class ScopeNode(BaseNode):
self,
stmt: Optional["rql.stmts.Statement"] = None,
copy_solutions: bool = True,
solutions: rt.SolutionsList = None,
solutions: SolutionsList = None,
) -> "rql.base.BaseNode":
new = self.__class__()
if self.schema is not None:
......@@ -188,7 +191,7 @@ class ScopeNode(BaseNode):
def set_possible_types(
self,
solutions: rt.SolutionsList,
solutions: SolutionsList,
kwargs: Optional[Union_[object, Dict[str, str]]] = _MARKER,
key: str = "possibletypes",
) -> None:
......@@ -621,7 +624,7 @@ class Select(Statement, nodes.EditableMixIn, ScopeNode):
self,
stmt: Optional["rql.stmts.Statement"] = None,
copy_solutions: bool = True,
solutions: Optional[rt.SolutionsList] = None,
solutions: Optional[SolutionsList] = None,
) -> "rql.stmts.Select":
new = super().copy(self, copy_solutions, solutions)
......@@ -652,7 +655,7 @@ class Select(Statement, nodes.EditableMixIn, ScopeNode):
def set_possible_types(
self,
solutions: rt.SolutionsList,
solutions: SolutionsList,
kwargs: Optional[Union_[object, Dict[str, str]]] = _MARKER,
key: str = "possibletypes",
) -> None:
......@@ -789,7 +792,7 @@ class Select(Statement, nodes.EditableMixIn, ScopeNode):
return self.aliases[name]
return super(Select, self).get_variable(name)
def clean_solutions(self, solutions: Optional[rt.SolutionsList] = None) -> None:
def clean_solutions(self, solutions: Optional[SolutionsList] = None) -> None:
"""when a rqlst has been extracted from another, this method returns
solutions which make sense for this sub syntax tree
"""
......@@ -800,9 +803,9 @@ class Select(Statement, nodes.EditableMixIn, ScopeNode):
if not (self.defined_vars or self.aliases):
self.solutions = [{}]
else:
newsolutions: rt.SolutionsList = []
newsolutions: SolutionsList = []
for origsol in solutions:
asol: rt.Solution = {}
asol: Solution = {}
for var in self.defined_vars:
asol[var] = origsol[var]
for var in self.aliases:
......
Markdown is supported
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