Skip to content

Commit 77d2472

Browse files
committed
add some appropriate "# pragma: no cover"
1 parent 52831a9 commit 77d2472

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

unpythonic/syntax/nb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def nb(body, args):
1616
p = args[0] if args else q[print] # custom print function hook
1717
newbody = []
18-
with q as init:
18+
with q as init: # pragma: no cover, quoted only.
1919
_ = None
2020
theprint = ast_literal[p]
2121
newbody.extend(init)
@@ -27,7 +27,7 @@ def nb(body, args):
2727
if type(stmt) is not Expr or istestmacro(stmt.value):
2828
newbody.append(stmt)
2929
continue
30-
with q as newstmts:
30+
with q as newstmts: # pragma: no cover, quoted only.
3131
_ = ast_literal[stmt.value]
3232
if _ is not None:
3333
theprint(_)

unpythonic/syntax/prefix.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def transform(tree, *, quotelevel, set_ctx, stop, **kw):
4545
view = UnexpandedLetView(tree)
4646
for binding in view.bindings:
4747
if type(binding) is not Tuple:
48-
assert False, "prefix: expected a tuple in let binding position"
48+
assert False, "prefix: expected a tuple in let binding position" # pragma: no cover
4949
_, value = binding.elts # leave name alone, recurse into value
5050
binding.elts[1] = transform.recurse(value, quotelevel=quotelevel)
5151
if view.body:
@@ -61,7 +61,7 @@ def transform(tree, *, quotelevel, set_ctx, stop, **kw):
6161
if isunexpandedtestmacro(tree):
6262
stop()
6363
if type(tree.slice) is not Index:
64-
assert False, "prefix: Slice and ExtSlice not implemented in analysis of testing macro arguments"
64+
assert False, "prefix: Slice and ExtSlice not implemented in analysis of testing macro arguments" # pragma: no cover
6565
body = tree.slice.value
6666
if type(body) is Tuple:
6767
# skip the transformation of the argument tuple itself, but transform its elements
@@ -78,31 +78,31 @@ def transform(tree, *, quotelevel, set_ctx, stop, **kw):
7878
while True:
7979
if isunquote(op):
8080
if quotelevel < 1:
81-
assert False, "unquote while not in quote"
81+
assert False, "unquote while not in quote" # pragma: no cover
8282
quotelevel -= 1
8383
elif isquote(op):
8484
quotelevel += 1
8585
else:
8686
break
8787
set_ctx(quotelevel=quotelevel)
8888
if not len(data):
89-
assert False, "a prefix tuple cannot contain only quote/unquote operators"
89+
assert False, "a prefix tuple cannot contain only quote/unquote operators" # pragma: no cover
9090
op, *data = data
9191
if quotelevel > 0:
9292
quoted = [op] + data
9393
if any(iskwargs(x) for x in quoted):
94-
assert False, "kw(...) may only appear in a prefix tuple representing a function call"
94+
assert False, "kw(...) may only appear in a prefix tuple representing a function call" # pragma: no cover
9595
return q[(ast_literal[quoted],)]
9696
# (f, a1, ..., an) --> f(a1, ..., an)
9797
posargs = [x for x in data if not iskwargs(x)]
9898
# TODO: tag *args and **kwargs in a kw() as invalid, too (currently just ignored)
9999
invalids = list(flatmap(lambda x: x.args, filter(iskwargs, data)))
100100
if invalids:
101-
assert False, "kw(...) may only specify named args"
101+
assert False, "kw(...) may only specify named args" # pragma: no cover
102102
kwargs = flatmap(lambda x: x.keywords, filter(iskwargs, data))
103103
kwargs = list(rev(uniqify(rev(kwargs), key=lambda x: x.arg))) # latest wins, but keep original ordering
104104
thecall = Call(func=op, args=posargs, keywords=list(kwargs))
105-
if PYTHON34: # Python 3.4 only
105+
if PYTHON34: # pragma: no cover, Python 3.4 only
106106
thecall.starargs = None
107107
thecall.kwargs = None
108108
return thecall
@@ -115,17 +115,17 @@ def transform(tree, *, quotelevel, set_ctx, stop, **kw):
115115
# namely the stubs for the "q" and "u" markers used within a `prefix` block.
116116
class q: # noqa: F811
117117
"""[syntax] Quote operator. Only meaningful in a tuple in a prefix block."""
118-
def __repr__(self): # in case one of these ends up somewhere at runtime
118+
def __repr__(self): # in case one of these ends up somewhere at runtime # pragma: no cover
119119
return "<quote>"
120120
q = q()
121121

122122
class u: # noqa: F811
123123
"""[syntax] Unquote operator. Only meaningful in a tuple in a prefix block."""
124-
def __repr__(self): # in case one of these ends up somewhere at runtime
124+
def __repr__(self): # in case one of these ends up somewhere at runtime # pragma: no cover
125125
return "<unquote>"
126126
u = u()
127127

128128
# not a @macro_stub; it only raises a run-time error on foo[...], not foo(...)
129129
def kw(**kwargs):
130130
"""[syntax] Pass-named-args operator. Only meaningful in a tuple in a prefix block."""
131-
raise RuntimeError("kw only meaningful inside a tuple in a prefix block")
131+
raise RuntimeError("kw only meaningful inside a tuple in a prefix block") # pragma: no cover

0 commit comments

Comments
 (0)