Repository navigation
Conversation
…doit#390) - BaseAction.title(): short description of an action, overridable. CmdAction shows the expanded command line (callables that generate the command are described, never called, see pydoit#437). PythonAction shows `func(args, key=value)`. - Reporters get `execute_action(task, action)`, called by Task.execute() and Task.execute_teardown() before each action. ConsoleReporter prints ` + <title>` when `show_action` is set. Reporters that do not implement it keep working. - MReporter forwards the action title from sub-processes. - fix CmdAction.__str__ raising TypeError when the action is a tuple. Builds on the design started in pydoit#392. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #390. Continues the work started in #392.
What it does
Follows the TODO list in #390:
--show-action(also settable fromDOIT_CONFIGasshow_action)title()method for actionsBaseAction.title()returnsstr(self), so custom actions work and can override itCmdAction: the expanded command line (%(targets)setc. substituted); list commands are shown withshlex.joinPythonAction:func(arg, key=value)using the args/kwargs from the task definitionexecute_action(task, action)Task.execute()/execute_teardown()take an optionalreporterand call it before each action, including teardown actionsConsoleReporterprints+ <title>only whenshow_actionis set; it skips hidden_tasks, likeexecute_taskZeroReporter/ErrorOnlyReporter/JsonReporter: no-opexecute_action(existing plugins) keep working; it is looked up withgetattrDifferences from #392
isinstance(reporter, ConsoleReporter)check inTask. Any reporter can implement the hook, andtask.pydoesn't importreporter.py.-n(process and thread runners).MReportersends the action title from the sub-process (actions may not be picklable), and the main process passes a small stand-in object with atitle()method to the real reporter.CmdActionwhose command is generated by a callable is described, not called (Cmd: make_cmd('x')). Calling it just to print it would run user code twice, the problem fixed in CmdAction calls callable more than once #437.title()never raises. If expansion fails, it shows the raw action, and the real error is still reported when the action runs.Also fixed
CmdAction.__str__raisedTypeErrorwhen the action was a tuple ("Cmd: %s" % self._action). It now uses% (self._action,).Known limitation (documented)
With
--process/-n, reporter calls go through the result queue, so the+lines can be printed out of order with the actions' own output. The task title line. namealready behaves this way. Thread mode and the default runner keep the order.While testing I also noticed that, on
master, teardown actions run twice with-n 2 -P thread(byeis printed twice). This PR doesn't change that. I can open a separate issue for it.Tests
tests/test_action.py: titles for str/expanded/list/callable/invalidCmdActionandPythonActiontests/test_reporter.py: console on/off/hidden task, zero/error-only/json no-optests/test_task.py: called before each action and teardown action, stops after failure, reporter without the methodtests/test_runner.py:Runner,MReporter,MRunner(process) andMThreadRunnertests/test_cmd_run.py: end-to-end option on/offrut: 861 passed. pyflakes clean, no new pycodestyle warnings. Docs added indoc/cmd-run.rstand an entry inCHANGES.🤖 Generated with Claude Code