feat: add support for providing serialized answers to multiselect choice questions
I've added support for providing serialized answers to multiselect choice questions.
This feature enables two use cases:
- The default value can be templated by rendering default choice items as a YAML-style list.
- An answer can be passed via the CLI flag
--dataas a YAML-style list. Resolves #1474.
The answer to a multiselect choice question is a list of choice items. While it seems that the most obvious solution is to parse the answer using a YAML parser, I think it's not the right approach because the list items should be parsed according to type: <type> and not necessarily using a YAML parser, and it's inconsistent with other question types to first parse them as YAML and afterwards parse according to type: <type>. But I've found a way to shallowly parse the serialized answer as a YAML-style list without parsing the items. This way, the items remain raw strings, delegating their parsing to the parser according to type: <type>. There is one subtlety: YAML strings may be quoted or (sometimes) unquoted. To avoid double-quoting after the shallow list parsing, the quotes of a YAML string are stripped.
Codecov Report
:x: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 97.89%. Comparing base (7f4a1f8) to head (f2ff775).
:warning: Report is 107 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| copier/_user_data.py | 92.85% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #2189 +/- ##
==========================================
- Coverage 98.03% 97.89% -0.14%
==========================================
Files 55 55
Lines 6005 6038 +33
==========================================
+ Hits 5887 5911 +24
- Misses 118 127 +9
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 97.89% <96.15%> (-0.14%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.