Exemple #1
0
def _merge(
    self,
    obj: Union[exactly(str),
               exactly(type(None)),
               exactly(bool),
               exactly(int),
               exactly(float), ],
    m1,
    m2,
):
    return m2
Exemple #2
0
 def _run(
     self,
     s: Union[exactly(str),
              exactly(type(None)),
              exactly(bool),
              exactly(int),
              exactly(float), ],
     *,
     depth,
 ):
     return H.atom(repr(s))
Exemple #3
0
    def _run(self, xs: exactly(tuple), *, depth):
        if depth == self.max_depth:
            return self.ref(xs)

        elems = [self.run(x, depth=depth + 1) for x in xs]
        if len(xs) == 1:
            elems.append(H.atom(""))
        return H.bracketed(elems, start="(", end=")", delimiter=", ")
Exemple #4
0
    def _run(self, xs: exactly(list), *, depth):
        if depth == self.max_depth:
            return self.ref(xs)

        return H.bracketed(
            [self.run(x, depth=depth + 1) for x in xs],
            start="[",
            end="]",
            delimiter=", ",
        )
Exemple #5
0
    def _run(self, xs: exactly(set), *, depth):
        if depth == self.max_depth:
            return self.ref(xs)

        if not xs:
            return H.atom("set()")
        else:
            return H.bracketed(
                [self.run(x, depth=depth + 1) for x in xs],
                start="{",
                end="}",
                delimiter=",",
            )
Exemple #6
0
    def _run(self, d: exactly(dict), *, depth):
        if depth == self.max_depth:
            return self.ref(d)

        items = list(d.items())
        return H.bracketed(
            [
                H.pair(
                    self.run(k, depth=depth + 1),
                    self.run(v, depth=depth + 1),
                    delimiter=": ",
                ) for k, v in items
            ],
            start="{",
            end="}",
            delimiter=", ",
        )
Exemple #7
0
 def f(x: exactly(Fruit)):
     return "yes"