Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Drop unused func in future.py
Browse files Browse the repository at this point in the history
  • Loading branch information
seandstewart committed Feb 28, 2024
1 parent eb2e3f7 commit d0f90a7
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/typical/core/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,6 @@ def transform_annotation(annotation: str, *, union: str = "Union") -> str:
return unparsed


def write_anno_expr(
tree: ast.Expression | ast.Name | ast.Subscript | ast.Attribute | ast.expr,
):
expr = tree.body if isinstance(tree, ast.Expression) else tree
if isinstance(expr, ast.Name):
return expr.id
if isinstance(expr, ast.Subscript):
val = expr.slice.value # type: ignore[attr-defined]
if isinstance(val, ast.Tuple):
subscript = ", ".join(write_anno_expr(c) for c in val.elts)
else:
subscript = write_anno_expr(val)
return f"{write_anno_expr(expr.value)}[{subscript}]"
if isinstance(expr, ast.List):
children = ", ".join(write_anno_expr(c) for c in expr.elts)
return f"[{children}]"
if isinstance(expr, ast.Constant):
return str(expr.value)

if isinstance(expr, ast.Attribute):
return expr.attr

raise ValueError(ast.dump(tree))


class TransformUnion(ast.NodeTransformer):
def visit_BinOp(self, node: ast.BinOp):
if not isinstance(node.op, ast.BitOr):
Expand Down Expand Up @@ -82,13 +57,6 @@ def visit_Name(self, node: ast.Name):
return new


def contained_generic(string: str) -> tuple[bool, int]:
opens = string.count("[")
closes = string.count("]")
hanging = opens - closes
return hanging == 0, hanging


_GENERICS = {
"dict": "typing.Dict",
"list": "typing.List",
Expand Down

0 comments on commit d0f90a7

Please sign in to comment.