From c4a2ec82e879f07c1dfbb185006f4547e06ac794db0b3544e789be913fd2f4b5 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 30 Apr 2025 05:00:54 +0000 Subject: [PATCH] - Add patch support-pydantic-211.patch: * Support Pydantic 2.11 changes by not calling model_fields on instances. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-psygnal?expand=0&rev=13 --- python-psygnal.changes | 7 +++++++ python-psygnal.spec | 6 ++---- support-pydantic-211.patch | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 support-pydantic-211.patch diff --git a/python-psygnal.changes b/python-psygnal.changes index 875a3e2..91b154c 100644 --- a/python-psygnal.changes +++ b/python-psygnal.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Apr 30 05:00:03 UTC 2025 - Steve Kowalik + +- Add patch support-pydantic-211.patch: + * Support Pydantic 2.11 changes by not calling model_fields on + instances. + ------------------------------------------------------------------- Tue Feb 4 16:20:22 UTC 2025 - Dirk Müller diff --git a/python-psygnal.spec b/python-psygnal.spec index f4a7a30..034e6f6 100644 --- a/python-psygnal.spec +++ b/python-psygnal.spec @@ -23,12 +23,13 @@ Summary: Fast python callback/event system modeled after Qt Signals License: BSD-3-Clause URL: https://github.com/pyapp-kit/psygnal Source: https://files.pythonhosted.org/packages/source/p/psygnal/psygnal-%{version}.tar.gz +# PATCH-FIX-UPSTREAM gh#pyapp-kit/psygnal#364 +Patch0: support-pydantic-211.patch BuildRequires: %{python_module hatch-vcs} BuildRequires: %{python_module hatchling >= 1.8.0} BuildRequires: %{python_module pip} BuildRequires: python-rpm-macros # SECTION test requirements -BuildRequires: %{python_module mypy_extensions} BuildRequires: %{python_module attrs} BuildRequires: %{python_module dask} BuildRequires: %{python_module msgspec} @@ -37,12 +38,9 @@ BuildRequires: %{python_module pydantic} BuildRequires: %{python_module pytest >= 6.0} BuildRequires: %{python_module pytest-cov} BuildRequires: %{python_module toolz} -BuildRequires: %{python_module typing-extensions >= 3.7.4.2} BuildRequires: %{python_module wrapt} # /SECTION BuildRequires: fdupes -Requires: python-mypy_extensions -Requires: python-typing-extensions >= 3.7.4.2 Suggests: python-dask Suggests: python-ipython Suggests: python-numpy diff --git a/support-pydantic-211.patch b/support-pydantic-211.patch new file mode 100644 index 0000000..4f30f1f --- /dev/null +++ b/support-pydantic-211.patch @@ -0,0 +1,35 @@ +From e26b74711c598d383112c3450e044d6389fd8be8 Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Wed, 30 Apr 2025 14:53:55 +1000 +Subject: [PATCH] Don't use deprecated model_fields access + +Pydantic 2.11 has deprecated accessing model_fields from instances of +the model class, instead requiring callers to use the class itself. + +Fixes #356 +--- + src/psygnal/_evented_model.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/psygnal/_evented_model.py b/src/psygnal/_evented_model.py +index 31f90f98..c1cf1c57 100644 +--- a/src/psygnal/_evented_model.py ++++ b/src/psygnal/_evented_model.py +@@ -111,7 +111,7 @@ def _get_defaults( + ) -> dict[str, Any]: + """Get possibly nested default values for a Model object.""" + dflt = {} +- for k, v in obj.model_fields.items(): ++ for k, v in type(obj).model_fields.items(): + d = v.get_default() + if ( + d is None +@@ -547,7 +547,7 @@ def update(self, values: Union["EventedModel", dict], recurse: bool = True) -> N + def reset(self) -> None: + """Reset the state of the model to default values.""" + model_config = _get_config(self) +- model_fields = _get_fields(self) ++ model_fields = _get_fields(type(self)) + for name, value in self._defaults.items(): + if isinstance(value, EventedModel): + cast("EventedModel", getattr(self, name)).reset()