Skip to content

forget: honor default_tasks from config and forget all tasks when nothing is selected - #496

Open
smoltafet wants to merge 1 commit into
pydoit:masterfrom
smoltafet:fix/forget-default-tasks
Open

smoltafet wants to merge 1 commit into
pydoit:masterfrom
smoltafet:fix/forget-default-tasks

Conversation

@smoltafet

Copy link
Copy Markdown

Fixes #478 and #469.

#478 — doit forget crashes when no default_tasks are configured. With no task names on the command line and no default_tasks, Forget._execute iterated over self.sel_tasks, which is None in that case, raising TypeError: 'NoneType' object is not iterable. run and clean already treat "nothing selected" as "all tasks" (clean checks sel_tasks is not None explicitly), so forget now does the same: it forgets every task. The collected list is de-duplicated, since a list built from all tasks contains group subtasks twice (once directly, once via the group), and dependencies shared by several selected tasks would otherwise be forgotten (and reported) repeatedly.

#469 — default_tasks set via config file / DoitMain(extra_config=...) was ignored by forget. default_tasks is not a registered command option, so values in DoitMain's config (extra_config or INI/TOML files, both available as self.config_vals) were silently dropped by the option parser; only DOIT_CONFIG in the dodo file reached params, because execute() merges it wholesale. DoitCmdBase.execute now registers a config-supplied default_tasks as a default value before merging DOIT_CONFIG, which keeps the existing precedence (DOIT_CONFIG wins, as it does for regular options).

Tests: 4 new tests in tests/test_cmd_forget.py — unit tests for the no-selection case (plain and --follow-sub) and end-to-end tests through DoitMain for both issues. All 4 fail on the unmodified code. Full suite: 839 passed, with the same single pre-existing environment failure as on master (tests/test___main__.py::TestMain::test_execute, also failing without this change).

@smoltafet

Copy link
Copy Markdown
Author

Hi @schettino72, could you take a look at this when you have a moment? Happy to fix up anything that needs changing. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError using doit forget with no default tasks specified

1 participant