Compare commits

..

No commits in common. "bd34d4dffa0a892b276c42d9a3937fe7292cf553" and "5a95d57aff283af8fb34c8e62adfa678463e6e9c" have entirely different histories.

4 changed files with 23 additions and 102 deletions

View File

@ -1,60 +0,0 @@
From 5cf34f6c42b6e39aa1e53394443efca3d7329e3b Mon Sep 17 00:00:00 2001
From: azjps <azhu@tower-research.com>
Date: Fri, 19 Apr 2024 23:07:41 +1200
Subject: [PATCH] Fix assigning string value to Set (#903)
url:https://github.com/ipython/traitlets/pull/903/commits/4143e7eb0c3e474fe3cb031666b4620cf1e0d832
---
tests/test_traitlets.py | 18 ++++++++++++++++++
traitlets/traitlets.py | 7 +------
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/tests/test_traitlets.py b/tests/test_traitlets.py
index dfcf3f0..f9f623b 100644
--- a/tests/test_traitlets.py
+++ b/tests/test_traitlets.py
@@ -1658,6 +1658,24 @@ class TestList(TraitTestBase):
return value
+class SetTrait(HasTraits):
+ value = Set(Unicode())
+
+
+class TestSet(TraitTestBase):
+ obj = SetTrait()
+
+ _default_value: t.Set[str] = set()
+ _good_values = [{"a", "b"}, "ab"]
+ _bad_values = [1]
+
+ def coerce(self, value):
+ if isinstance(value, str):
+ # compatibility handling: convert string to set containing string
+ value = {value}
+ return value
+
+
class Foo:
pass
diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py
index 1d1675a..ecd0d7c 100644
--- a/traitlets/traitlets.py
+++ b/traitlets/traitlets.py
@@ -3698,12 +3698,7 @@ class Set(Container[t.Set[t.Any]]):
def set(self, obj: t.Any, value: t.Any) -> None:
if isinstance(value, str):
- return super().set(
- obj,
- set(
- value,
- ),
- )
+ return super().set(obj, {value})
else:
return super().set(obj, value)
--
2.27.0

View File

@ -1,71 +1,52 @@
Name: python-traitlets
Version: 5.14.1
Release: 2
Version: 4.3.2
Release: 11
Summary: A lightweight Traits like module.
License: BSD-3-Clause
URL: https://github.com/ipython/traitlets
Source0: https://files.pythonhosted.org/packages/source/t/traitlets/traitlets-%{version}.tar.gz
Patch0: backport-fix-assigning-string-value-to-Set.patch
Source0: https://github.com/ipython/traitlets/archive/%{version}.tar.gz#/traitlets-%{version}.tar.gz
BuildArch: noarch
%description
A framework that lets Python classes have attributes with type checking, dynamically calculated default values,
and callbacks.
and on change callbacks.
%package -n python3-traitlets
%package -n python%{python3_pkgversion}-traitlets
Summary: A lightweight Traits like module.
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
BuildRequires: python3-wheel
BuildRequires: python3-hatchling
BuildRequires: python3-pytest
%python_provide python3-traitlets
BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-decorator python%{python3_pkgversion}-six
BuildRequires: python%{python3_pkgversion}-ipython_genutils python%{python3_pkgversion}-six
Requires: python%{python3_pkgversion}-decorator python%{python3_pkgversion}-ipython_genutils python%{python3_pkgversion}-six
%python_provide python%{python3_pkgversion}-traitlets
%description -n python3-traitlets
%description -n python%{python3_pkgversion}-traitlets
A framework that lets Python classes have attributes with type checking, dynamically calculated default values,
and callbacks.
and on change callbacks.
%prep
%autosetup -n traitlets-%{version} -p1
%build
%pyproject_build
%py3_build
%install
%pyproject_install
%py3_install
%check
py.test-3 -v traitlets/tests/
py.test-%{python3_version} -v traitlets/tests/
%files -n python%{python3_pkgversion}-traitlets
%doc README.md COPYING.md
%{python3_sitelib}/*
%files -n python3-traitlets
%license LICENSE
%doc README.md
%{python3_sitelib}/traitlets/
%{python3_sitelib}/traitlets*.dist-info/
%changelog
* Sat May 11 2024 dongjiao <dongjiao@kylinos.cn> - 5.14.1-2
- bugfix:Fix assigning string value to Set
* Fri Mar 1 2024 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 5.14.1-1
- Upgrade package with version 5.14.1
Add option to load traitlets values from environement.
Cleanup after remove Python 2 support.
Add more project URLs, trove classifiers.
Added type hints to HasTraits.observe() and friends.
* Tue Apr 25 2023 yaoxin <yao_xin001@hoperun.com> - 5.9.0-1
- Update to 5.9.0
* Thu Aug 04 2022 liqiuyu <liqiuyu@kylinos.cn> - 5.3.0-1
- Update to 5.3.0
* Wed Jun 01 2022 yangping <yangping69@h-partners.com> - 5.1.1-1
- Update to v5.1.1
* Mon May 9 2022 yaoxin <yaoxin30@h-partners.com> - 4.3.2-11
- License compliance rectification

BIN
traitlets-4.3.2.tar.gz Normal file

Binary file not shown.

Binary file not shown.