- `ConfigData` objects now know where do answers come from.
- Their `.data` attribute is now a computed property that merges all those answer sources in priority order.
- To merge dicts, `ChainMap` is used extensively.
- `query_user_data` gets both `last_answer_data` and `forced_answers_data` instead of the single `answers_data` argument it got before.
- By knowing where does an answer come from, now Copier avoids asking something if the user already answered that from other source. For example, if you use `copier -d some_question=some_answer copy $src $dst`, then Copier will not ask you about `some_question` again, because you already answered that. 🎉
- All answer sources are deep-copied to avoid modifying mutable dicts and affecting further copier executions.
- A minimal amount of tests got updated as they were now supposed to fail with new behavior.
- Ignore flake8 `E501 line too long` errors. We use black, that's just unnecessarily annoying.
@Tecnativa TT23705
When data came from `--data` flag, it was always a string.
If some data was expected to be of another type, it could make the template fail.
The type casting system must be applied also to user answers, so here's the patch, docs and tests.
@Tecnativa TT20357
When using the `--data` CLI option, all incoming data are strings. This is the expected behavior because at this point we still don't know the expected types of all answers (we don't even know the questions).
Now the type casting is done smartly when strings come in any form.
There are 2 special cases handled here:
1. When the expected type is bool and the incoming data is string. Handled by YAML because strings like "false", "0" and "no" would evaluate to `True` otherwise.
2. When the expected type is JSON or YAML but the incoming data is not a string. This can only happen when data comes in from API calls (not CLI) or is loaded from default answers in `copier.yml`. In these cases, we don't need to do any type casting, because the input is already a scalar.
@Tecnativa TT20357
Fix#89 and fix#89 by adding a new extended syntax to make prompts way more usable.
Leverages plumbum's helpers, so prompt code is removed from Copier codebase, making it smaller BTW.
See README and the new test to understand the new features.
@Tecnativa TT20357