feat: support arbitrary field dependents
This is a proof of principle PR that would support the feature that @sjdemartini is requesting in https://github.com/pyapp-kit/psygnal/issues/337. namely:
- computed fields can gain events
- computed fields (really, currently any field) can list non-field attribute names as their dependents for checking event emission.
@Czaki, I would appreciate your eyes on this.
- I just "made it work" ... so there's likely some minor refactoring that should be done here to polish it (particularly in the
_check_if_values_changed_and_emit_if_neededarea that you had previously worked on) - Feel free to comment in general on the feature request. I think @sjdemartini motivated it quite nicely his comment, https://github.com/pyapp-kit/psygnal/issues/337#issuecomment-2472157973 ... so please read that for context; and for a quick use case example, see the new test I added in
test_private_field_dependents
closes #337
tests are failing during building of mypyc, due to https://github.com/pydantic/pydantic/issues/10907
CodSpeed Performance Report
Merging #340 will not alter performance
Comparing tlambert03:computed-fields (9e4f833) with main (185fc4e)
Summary
✅ 67 untouched benchmarks
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 99.86%. Comparing base (185fc4e) to head (9e4f833).
:warning: Report is 12 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #340 +/- ##
==========================================
- Coverage 99.91% 99.86% -0.05%
==========================================
Files 22 22
Lines 2230 2248 +18
==========================================
+ Hits 2228 2245 +17
- Misses 2 3 +1
: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.