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: emission of events from root validators and extraneous emission of dependent fields #234

Merged
merged 10 commits into from
Sep 18, 2023

Conversation

tlambert03
Copy link
Member

fixes #233

@andy-sweet, this implements option number 2 from #233 (comment)

  • property_dependencies can include any field names ... not just property setters
  • values of dependents are checked before and after setting and events are only emitted if necessary

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 16, 2023

CodSpeed Performance Report

Merging #234 will not alter performance

Comparing tlambert03:fix-root-validators (c85743f) with main (1255291)

Summary

✅ 66 untouched benchmarks

@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (1255291) 100.00% compared to head (c85743f) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #234   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         1829      1843   +14     
=========================================
+ Hits          1829      1843   +14     
Files Changed Coverage Δ
src/psygnal/_evented_model_v1.py 100.00% <100.00%> (ø)
src/psygnal/_evented_model_v2.py 100.00% <100.00%> (ø)

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

@tlambert03 tlambert03 changed the title fix: emission of events from root validators fix: emission of events from root validators and extraneous emission of dependent fields Sep 16, 2023
Copy link
Member

@andy-sweet andy-sweet left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for the fast fix. Just made a couple of nit-picking comments on implementation comment naming, which are optional.

src/psygnal/_evented_model_v1.py Outdated Show resolved Hide resolved
src/psygnal/_evented_model_v2.py Outdated Show resolved Hide resolved
src/psygnal/_evented_model_v2.py Outdated Show resolved Hide resolved
@andy-sweet
Copy link
Member

As discussed in #233, it probably also makes sense to rename property_dependencies with this solution. That doesn't have to happen in this PR, but there should be an issue to track it if this is merged without.

@tlambert03
Copy link
Member Author

agreed, did you have a thought on the exact name? As mentioned over there:

I like dependencies, but since the namespace is shared with all the other pydantic stuff, perhaps event_dependencies is safer/clearer? or do you like field_dependencies better than event_dependencies?

@tlambert03 tlambert03 merged commit 0d8f667 into pyapp-kit:main Sep 18, 2023
27 checks passed
@tlambert03 tlambert03 deleted the fix-root-validators branch September 18, 2023 19:51
@tlambert03 tlambert03 added the bug Something isn't working label Sep 19, 2023
sjdemartini added a commit to sjdemartini/psygnal that referenced this pull request Nov 8, 2024
`property_dependencies` was renamed to `field_dependencies` in pyapp-kit#234 but some associated error messages and docs still refer to the deprecated name.
tlambert03 pushed a commit that referenced this pull request Nov 8, 2024
`property_dependencies` was renamed to `field_dependencies` in #234 but some associated error messages and docs still refer to the deprecated name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

EventedModel does not emit events for all value changes in a root validator
2 participants