Skip to content

Commit 1a9e20b

Browse files
author
Michael Phelps
committed
Exclude bindings from code coverage (they are never actually executed, only inspected)
1 parent cc6eb7f commit 1a9e20b

File tree

6 files changed

+162
-234
lines changed

6 files changed

+162
-234
lines changed

pytago/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def python_to_go(python: str, debug=True) -> str:
88
return go_ast.unparse(go_tree, debug=debug)
99

1010

11-
def dump_python_to_go_ast_as_json(python: str):
11+
def dump_python_to_go_ast_as_json(python: str): # pragma: no cover
1212
from pytago import go_ast
1313
"""
1414
Not currently used for anything. Hoping that this could
@@ -42,7 +42,7 @@ def build_source_tree(source, *args, **kwargs) -> ast.Module:
4242
return tree
4343

4444
# Debugging
45-
if __name__ == '__main__':
45+
if __name__ == '__main__': # pragma: no cover
4646
print(dump_python_to_go_ast_as_json("""\
4747
def main():
4848
a = 7

pytago/go_ast/ast_snippets.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -177,79 +177,6 @@ def fstring(template_str: str, key_value_elements=list['ast.KeyValueExpr']) -> '
177177
)
178178

179179

180-
def defer_amid_panic(deferred_statements: list['ast.Stmt']) -> 'ast.DeferStmt':
181-
token = ast.token
182-
return ast.DeferStmt(
183-
Call=ast.CallExpr(
184-
Fun=ast.FuncLit(
185-
Type=ast.FuncType(
186-
Params=ast.FieldList(),
187-
),
188-
Body=ast.BlockStmt(
189-
List=[
190-
ast.IfStmt(
191-
Init=ast.AssignStmt(
192-
Lhs=[
193-
ast.Ident(
194-
Name="r",
195-
),
196-
],
197-
Tok=token.DEFINE,
198-
Rhs=[
199-
ast.CallExpr(
200-
Fun=ast.Ident(
201-
Name="recover",
202-
),
203-
),
204-
],
205-
),
206-
Cond=ast.BinaryExpr(
207-
X=ast.Ident(
208-
Name="r",
209-
),
210-
Op=token.NEQ,
211-
Y=ast.Ident(
212-
Name="nil",
213-
),
214-
),
215-
Body=ast.BlockStmt(
216-
List=[
217-
*deferred_statements,
218-
ast.ExprStmt(
219-
X=ast.CallExpr(
220-
Fun=ast.Ident(
221-
Name="panic",
222-
),
223-
Args=[
224-
ast.Ident(
225-
Name="r",
226-
),
227-
],
228-
),
229-
),
230-
],
231-
),
232-
),
233-
],
234-
),
235-
),
236-
),
237-
)
238-
239-
240-
def with_encloser(assignment_statements: list['ast.Stmt'],
241-
body_statements: list['ast.Stmt'],
242-
# exception_blocks: list[tuple['ast.Expr', list['ast.Stmt']]],
243-
closing_statements: list['ast.Stmt']
244-
):
245-
return [
246-
*assignment_statements,
247-
defer_amid_panic(closing_statements),
248-
*body_statements,
249-
*closing_statements,
250-
]
251-
252-
253180
def wrap_err(err: 'ast.Expr'):
254181
token = ast.token
255182
return ast.CallExpr(

pytago/go_ast/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _format(node, level=0):
134134
indent = ' ' * indent
135135
return _format(node)[0]
136136

137-
def dump_json(node, annotate_fields=True, include_attributes=False, *, indent=None):
137+
def dump_json(node, annotate_fields=True, include_attributes=False, *, indent=None): # pragma: no cover
138138
"""
139139
Return a formatted dump of the tree in node. If annotate_fields is true (by default),
140140
the returned string will show the names and the values for fields.

0 commit comments

Comments
 (0)