Skip to content

Commit cad2e00

Browse files
committed
Remove CodePrinter from the default actions if we already have a CodePrinter predicate.
1 parent 2fd58ce commit cad2e00

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/hunter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def trace(self, *predicates, **options):
106106
options: Keyword arguments that are passed to :class:`hunter.Q`, for convenience.
107107
"""
108108
if "action" not in options and "actions" not in options:
109-
options["action"] = CodePrinter()
109+
options["action"] = CodePrinter
110110
merge = options.pop("merge", True)
111111
predicate = Q(*predicates, **options)
112112

@@ -252,6 +252,9 @@ def Q(*predicates, **query):
252252
p() if inspect.isclass(p) and issubclass(p, Action) else p
253253
for p in predicates
254254
)
255+
if any(isinstance(p, CodePrinter) for p in predicates):
256+
if CodePrinter in optional_actions:
257+
optional_actions.remove(CodePrinter)
255258
if query:
256259
predicates += Query(**query),
257260

0 commit comments

Comments
 (0)