Skip to content

Conversation

@DanCardin
Copy link
Owner

@DanCardin DanCardin commented Sep 4, 2025

Fixes #238

Move Resolved handling backwards into the mapping phase, which should allow for async functions integrated into

  • defaults
  • maybe completions
  • possibly parsing

We should also add an optional input for an ExitStack so the context can exceed the lifetime of the CLI itself?

Utilize Resolved to defer evaluation of default values, and as a result construction of the object graph instances until parse_command has completed. This enables invoke_async to then evaluate any deferred async function calls inside of a proper async context.

To do:

  • async ValueFrom tests
  • async and/or async-to-sync-and-back default sequence evaluation. It's possible this needs to be plumbed deeper for this
  • test async parse function? this might have been pseudo implemented automatically. not necessarily sure this is imporatnt to deliver but if it is automatic/easy might as well. (it'll run into the same sequencing problems as defaults)
  • test for global async deps which rely on the context remaining open for the duration of the invocation (tempfile?)
  • look over the general changes. this is both sort-of more complex (in particular the error handling and async/sync handling bits) but also has some kind of elegent simplicity to it as well. Certainly it m

@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 96.77419% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.54%. Comparing base (0c9f746) to head (e9ffd11).

Files with missing lines Patch % Lines
src/cappa/command.py 88.88% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #239      +/-   ##
==========================================
- Coverage   99.77%   99.54%   -0.23%     
==========================================
  Files          26       28       +2     
  Lines        2610     2658      +48     
  Branches      570      580      +10     
==========================================
+ Hits         2604     2646      +42     
- Misses          6       11       +5     
- Partials        0        1       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

How do I call an async function in ValueFrom?

2 participants