Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(updating): unset invalid last answers #1589

Merged
merged 1 commit into from Apr 20, 2024

Conversation

sisp
Copy link
Member

@sisp sisp commented Apr 16, 2024

I've fixed a bug related to handling invalid last answers which caused Copier to raise an exception while updating a project. The solution is to unset a previously recorded answer if parsing or validation fails. For instance, a choice question with choice item validators will fall back to either its default value or the first enabled choice item. In interactive mode without the --defaults switch, the user will be given the opportunity to select a valid answer again.

Fixes #1483.

@sisp sisp marked this pull request as draft April 16, 2024 16:53
@sisp sisp force-pushed the fix/unset-invalid-last-answers branch from e4e65a9 to 0889f52 Compare April 16, 2024 16:55
@sisp sisp marked this pull request as ready for review April 16, 2024 16:55
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 97.14286% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 97.22%. Comparing base (69662e3) to head (f237c94).

Files Patch % Lines
copier/main.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1589      +/-   ##
==========================================
- Coverage   97.33%   97.22%   -0.11%     
==========================================
  Files          48       48              
  Lines        4685     4719      +34     
==========================================
+ Hits         4560     4588      +28     
- Misses        125      131       +6     
Flag Coverage Δ
unittests 97.22% <97.14%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sisp sisp force-pushed the fix/unset-invalid-last-answers branch from 0889f52 to eaa4e25 Compare April 16, 2024 17:06
@sisp
Copy link
Member Author

sisp commented Apr 16, 2024

I have sadly resorted to noqa: C901 for Worker._ask()

def _ask(self) -> None: # noqa: C901

because I don't see an easy opportunity for reducing the complexity of this method.

@sisp sisp force-pushed the fix/unset-invalid-last-answers branch from eaa4e25 to 5f67017 Compare April 16, 2024 20:32
@sisp sisp force-pushed the fix/unset-invalid-last-answers branch from 5f67017 to f237c94 Compare April 18, 2024 13:48
@yajo yajo merged commit 51fdd3b into copier-org:master Apr 20, 2024
19 of 21 checks passed
@sisp sisp deleted the fix/unset-invalid-last-answers branch April 20, 2024 08:42
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.

bug: copier update throws error if previously selected value is disabled
2 participants