diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/util/unparse/unparser.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/util/unparse/unparser.py b/lib/spack/spack/util/unparse/unparser.py index 75f61e53f9..27dba8f287 100644 --- a/lib/spack/spack/util/unparse/unparser.py +++ b/lib/spack/spack/util/unparse/unparser.py @@ -380,6 +380,10 @@ class Unparser: self.fill("@") self.dispatch(deco) self.fill("class " + node.name) + if getattr(node, "type_params", False): + self.write("[") + interleave(lambda: self.write(", "), self.dispatch, node.type_params) + self.write("]") with self.delimit_if("(", ")", condition=node.bases or node.keywords): comma = False for e in node.bases: @@ -425,6 +429,10 @@ class Unparser: self.dispatch(deco) def_str = fill_suffix + " " + node.name self.fill(def_str) + if getattr(node, "type_params", False): + self.write("[") + interleave(lambda: self.write(", "), self.dispatch, node.type_params) + self.write("]") with self.delimit("(", ")"): self.dispatch(node.args) if getattr(node, "returns", False): @@ -1138,3 +1146,23 @@ class Unparser: with self.require_parens(_Precedence.BOR, node): self.set_precedence(pnext(_Precedence.BOR), *node.patterns) interleave(lambda: self.write(" | "), self.dispatch, node.patterns) + + def visit_TypeAlias(self, node): + self.fill("type ") + self.dispatch(node.name) + self.write(" = ") + self.dispatch(node.value) + + def visit_TypeVar(self, node): + self.write(node.name) + if node.bound: + self.write(": ") + self.dispatch(node.bound) + + def visit_TypeVarTuple(self, node): + self.write("*") + self.write(node.name) + + def visit_ParamSpec(self, node): + self.write("**") + self.write(node.name) |