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

feat: support for evented containers as pydantic v2 fields #283

Closed tlambert03 closed 8 months ago

tlambert03 commented 8 months ago

This is in support of #252, where I noted that evented containers don't work well as fields for pydantic models. Specifically, this enables:

class Model(pydantic.BaseModel):
    my_list: psygnal.containers.EventedList[int]  # or other evented containers

This only supports pydantic v2 (for now, and probably forever), since pydantic v1 always had very bad support for custom Generic fields

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (8f44f34) to head (b239e9a).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #283 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 22 22 Lines 1864 1880 +16 ========================================= + Hits 1864 1880 +16 ```

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

codspeed-hq[bot] commented 8 months ago

CodSpeed Performance Report

Merging #283 will not alter performance

Comparing tlambert03:pydantic-fields (b239e9a) with main (8f44f34)

Summary

✅ 66 untouched benchmarks