pyapp-kit / psygnal

Python observer pattern (callback/event system). Modeled after Qt Signals & Slots (but independent of Qt)
https://psygnal.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
84 stars 13 forks source link

fix: emission of events from root validators and extraneous emission of dependent fields #234

Closed tlambert03 closed 1 year ago

tlambert03 commented 1 year ago

fixes #233

@andy-sweet, this implements option number 2 from https://github.com/pyapp-kit/psygnal/issues/233#issuecomment-1722301583

codspeed-hq[bot] commented 1 year ago

CodSpeed Performance Report

Merging #234 will not alter performance

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

Summary

✅ 66 untouched benchmarks

codecov[bot] commented 1 year ago

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 ```diff @@ Coverage Diff @@ ## main #234 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 22 22 Lines 1829 1843 +14 ========================================= + Hits 1829 1843 +14 ``` | [Files Changed](https://app.codecov.io/gh/pyapp-kit/psygnal/pull/234?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit) | Coverage Δ | | |---|---|---| | [src/psygnal/\_evented\_model\_v1.py](https://app.codecov.io/gh/pyapp-kit/psygnal/pull/234?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3BzeWduYWwvX2V2ZW50ZWRfbW9kZWxfdjEucHk=) | `100.00% <100.00%> (ø)` | | | [src/psygnal/\_evented\_model\_v2.py](https://app.codecov.io/gh/pyapp-kit/psygnal/pull/234?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3BzeWduYWwvX2V2ZW50ZWRfbW9kZWxfdjIucHk=) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

andy-sweet commented 1 year ago

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 commented 1 year ago

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?