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

feat: add support for computed values via skipped questions #1220

Merged
merged 4 commits into from
Jul 8, 2023

Conversation

sisp
Copy link
Member

@sisp sisp commented Jun 29, 2023

I've added support for a long awaited feature: computed values via skipped questions (when: false). 🎉 See #1206 (comment) for more details.

Supersedes #1206. Resolves #1204 #1205. Resolves (I guess ...) #1203. 😜

@codecov
Copy link

codecov bot commented Jun 29, 2023

Codecov Report

Merging #1220 (a491e48) into master (1b351bc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1220   +/-   ##
=======================================
  Coverage   96.74%   96.75%           
=======================================
  Files          47       47           
  Lines        3935     3942    +7     
=======================================
+ Hits         3807     3814    +7     
  Misses        128      128           
Flag Coverage Δ
unittests 96.75% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
copier/template.py 96.31% <ø> (-0.06%) ⬇️
copier/main.py 95.66% <100.00%> (+0.01%) ⬆️
copier/user_data.py 94.53% <100.00%> (-0.12%) ⬇️
tests/test_complex_questions.py 100.00% <100.00%> (ø)
tests/test_prompt.py 91.42% <100.00%> (+0.08%) ⬆️

... and 1 file with indirect coverage changes

@yajo yajo linked an issue Jun 29, 2023 that may be closed by this pull request
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little improvement for docs. The rest looks great!

docs/configuring.md Outdated Show resolved Hide resolved
docs/configuring.md Outdated Show resolved Hide resolved
@yajo
Copy link
Member

yajo commented Jun 29, 2023

I'm thinking... We're just adding a feature, but what if a template relied on the fact that a skipped question was always missing? Should we label this as a breaking change? 🤔

Co-authored-by: Jairo Llopis <973709+yajo@users.noreply.github.com>
@sisp
Copy link
Member Author

sisp commented Jun 29, 2023

Missing in the context? For this to be breaking, an injected variable through an extension like the context hooks one would need to have the same name as the skipped question. I guess, it can be breaking in rare cases. 🤔

I forgot to edit the inline comments to describe the new behavior. I'll push a commit with corrected comments in a moment.

@yajo
Copy link
Member

yajo commented Jun 29, 2023

Well, the feature was never supported, so after all any breakages would come from unsupported use. Thus we can consider this a normal improvement.

@yajo yajo enabled auto-merge (squash) June 29, 2023 15:50
@sisp
Copy link
Member Author

sisp commented Jun 29, 2023

I think this PR isn't quite right yet. We should make sure that a skipped question's answer can only ever be its default value but not a value passed via --data or read from an edited answers file. I'll look into it.

@sisp sisp marked this pull request as draft June 29, 2023 15:56
auto-merge was automatically disabled June 29, 2023 15:56

Pull request was converted to draft

@yajo
Copy link
Member

yajo commented Jun 29, 2023

not a value passed via --data or read from an edited answers file

I think you don't need to care so deeply for this. Those are either weird or unsupported use cases anyways. If you do them, you know you're gonna get something wrong, so it should be OK for us IMHO.

@sisp sisp marked this pull request as ready for review June 29, 2023 17:02
@sisp
Copy link
Member Author

sisp commented Jun 29, 2023

Alright, I guess we can keep it like it is now to ship it more quickly, possibly add more rigor later for those anyway weird cases.

@sisp sisp enabled auto-merge (squash) June 29, 2023 17:04
@yajo
Copy link
Member

yajo commented Jul 8, 2023

It seems you have style violations. Could you run pre-commit please?

@sisp
Copy link
Member Author

sisp commented Jul 8, 2023

Ooops, yes, should be fixed now.

@sisp sisp disabled auto-merge July 8, 2023 10:27
@sisp sisp enabled auto-merge July 8, 2023 10:27
@sisp sisp disabled auto-merge July 8, 2023 10:27
@sisp sisp enabled auto-merge (squash) July 8, 2023 10:27
@sisp sisp merged commit 1e81fd5 into copier-org:master Jul 8, 2023
20 checks passed
@pawamoy
Copy link
Contributor

pawamoy commented Jul 8, 2023

Best PR 🥲 Many users will be super happy about this!

@sisp sisp deleted the feat/computed-values branch July 8, 2023 13:12
@tlambert03
Copy link
Contributor

thanks for your work on this @sisp!

I can confirm that with this PR, my template at https://github.com/pydev-guide/pyrepo-copier works as it did before v8

@sisp
Copy link
Member Author

sisp commented Jul 8, 2023

More important is @yajo's careful assessment about the best implementation of this feature.

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.

Support hidden variables without user prompt/input
4 participants