Accepting request 1244260 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/1244260 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-itemadapter?expand=0&rev=7
This commit is contained in:
commit
be26625444
3
itemadapter-0.11.0.tar.gz
Normal file
3
itemadapter-0.11.0.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4f5db3ba87d4b9938965f7d208a645cfd6563cdcd2166eb0cadb6a9acb6b08bd
|
||||
size 19493
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2d848f6a9815161d97aaa18c663766e045c3daa92f98d921a3cd594b6161972f
|
||||
size 17324
|
148
pydantic2.patch
148
pydantic2.patch
@ -1,148 +0,0 @@
|
||||
Index: itemadapter-0.8.0/README.md
|
||||
===================================================================
|
||||
--- itemadapter-0.8.0.orig/README.md
|
||||
+++ itemadapter-0.8.0/README.md
|
||||
@@ -193,7 +193,7 @@ The returned value is taken from the fol
|
||||
for `dataclass`-based items
|
||||
* [`attr.Attribute.metadata`](https://www.attrs.org/en/stable/examples.html#metadata)
|
||||
for `attrs`-based items
|
||||
- * [`pydantic.fields.FieldInfo`](https://pydantic-docs.helpmanual.io/usage/schema/#field-customisation)
|
||||
+ * [`pydantic.fields.FieldInfo`](https://docs.pydantic.dev/latest/api/fields/#pydantic.fields.FieldInfo)
|
||||
for `pydantic`-based items
|
||||
|
||||
#### class method `get_field_names_from_class(item_class: type) -> Optional[list[str]]`
|
||||
Index: itemadapter-0.8.0/itemadapter/adapter.py
|
||||
===================================================================
|
||||
--- itemadapter-0.8.0.orig/itemadapter/adapter.py
|
||||
+++ itemadapter-0.8.0/itemadapter/adapter.py
|
||||
@@ -179,24 +179,24 @@ class PydanticAdapter(AdapterInterface):
|
||||
|
||||
@classmethod
|
||||
def get_field_names_from_class(cls, item_class: type) -> Optional[List[str]]:
|
||||
- return list(item_class.__fields__.keys()) # type: ignore[attr-defined]
|
||||
+ return list(item_class.model_fields.keys()) # type: ignore[attr-defined]
|
||||
|
||||
def field_names(self) -> KeysView:
|
||||
- return KeysView(self.item.__fields__)
|
||||
+ return KeysView(self.item.model_fields)
|
||||
|
||||
def __getitem__(self, field_name: str) -> Any:
|
||||
- if field_name in self.item.__fields__:
|
||||
+ if field_name in self.item.model_fields:
|
||||
return getattr(self.item, field_name)
|
||||
raise KeyError(field_name)
|
||||
|
||||
def __setitem__(self, field_name: str, value: Any) -> None:
|
||||
- if field_name in self.item.__fields__:
|
||||
+ if field_name in self.item.model_fields:
|
||||
setattr(self.item, field_name, value)
|
||||
else:
|
||||
raise KeyError(f"{self.item.__class__.__name__} does not support field: {field_name}")
|
||||
|
||||
def __delitem__(self, field_name: str) -> None:
|
||||
- if field_name in self.item.__fields__:
|
||||
+ if field_name in self.item.model_fields:
|
||||
try:
|
||||
delattr(self.item, field_name)
|
||||
except AttributeError:
|
||||
@@ -205,7 +205,7 @@ class PydanticAdapter(AdapterInterface):
|
||||
raise KeyError(f"{self.item.__class__.__name__} does not support field: {field_name}")
|
||||
|
||||
def __iter__(self) -> Iterator:
|
||||
- return iter(attr for attr in self.item.__fields__ if hasattr(self.item, attr))
|
||||
+ return iter(attr for attr in self.item.model_fields if hasattr(self.item, attr))
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(list(iter(self)))
|
||||
Index: itemadapter-0.8.0/itemadapter/utils.py
|
||||
===================================================================
|
||||
--- itemadapter-0.8.0.orig/itemadapter/utils.py
|
||||
+++ itemadapter-0.8.0/itemadapter/utils.py
|
||||
@@ -23,30 +23,21 @@ def _is_pydantic_model(obj: Any) -> bool
|
||||
|
||||
def _get_pydantic_model_metadata(item_model: Any, field_name: str) -> MappingProxyType:
|
||||
metadata = {}
|
||||
- field = item_model.__fields__[field_name].field_info
|
||||
+ field = item_model.model_fields[field_name]
|
||||
|
||||
for attribute in [
|
||||
"alias",
|
||||
"title",
|
||||
"description",
|
||||
- "const",
|
||||
- "gt",
|
||||
- "ge",
|
||||
- "lt",
|
||||
- "le",
|
||||
- "multiple_of",
|
||||
- "min_items",
|
||||
- "max_items",
|
||||
- "min_length",
|
||||
- "max_length",
|
||||
- "regex",
|
||||
]:
|
||||
value = getattr(field, attribute)
|
||||
if value is not None:
|
||||
metadata[attribute] = value
|
||||
- if not field.allow_mutation:
|
||||
- metadata["allow_mutation"] = field.allow_mutation
|
||||
- metadata.update(field.extra)
|
||||
+ if field.frozen is not None:
|
||||
+ metadata["frozen"] = field.frozen
|
||||
+
|
||||
+ if field.json_schema_extra is not None:
|
||||
+ metadata.update(field.json_schema_extra)
|
||||
|
||||
return MappingProxyType(metadata)
|
||||
|
||||
Index: itemadapter-0.8.0/tests/__init__.py
|
||||
===================================================================
|
||||
--- itemadapter-0.8.0.orig/tests/__init__.py
|
||||
+++ itemadapter-0.8.0/tests/__init__.py
|
||||
@@ -102,7 +102,7 @@ else:
|
||||
|
||||
|
||||
try:
|
||||
- from pydantic import BaseModel, Field as PydanticField
|
||||
+ from pydantic import ConfigDict, BaseModel, Field as PydanticField
|
||||
except ImportError:
|
||||
PydanticModel = None
|
||||
PydanticSpecialCasesModel = None
|
||||
@@ -125,11 +125,9 @@ else:
|
||||
special_cases: Optional[int] = PydanticField(
|
||||
default_factory=lambda: None,
|
||||
alias="special_cases",
|
||||
- allow_mutation=False,
|
||||
+ frozen=False,
|
||||
)
|
||||
-
|
||||
- class Config:
|
||||
- validate_assignment = True
|
||||
+ model_config = ConfigDict(validate_assignment=True)
|
||||
|
||||
class PydanticModelNested(BaseModel):
|
||||
nested: PydanticModel
|
||||
@@ -139,9 +137,7 @@ else:
|
||||
set_: set
|
||||
tuple_: tuple
|
||||
int_: int
|
||||
-
|
||||
- class Config:
|
||||
- arbitrary_types_allowed = True
|
||||
+ model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
class PydanticModelSubclassed(PydanticModel):
|
||||
subclassed: bool = PydanticField(
|
||||
Index: itemadapter-0.8.0/tests/test_adapter_pydantic.py
|
||||
===================================================================
|
||||
--- itemadapter-0.8.0.orig/tests/test_adapter_pydantic.py
|
||||
+++ itemadapter-0.8.0/tests/test_adapter_pydantic.py
|
||||
@@ -73,7 +73,7 @@ class DataclassTestCase(unittest.TestCas
|
||||
)
|
||||
self.assertEqual(
|
||||
get_field_meta_from_class(PydanticSpecialCasesModel, "special_cases"),
|
||||
- MappingProxyType({"alias": "special_cases", "allow_mutation": False}),
|
||||
+ MappingProxyType({"alias": "special_cases", "frozen": False}),
|
||||
)
|
||||
with self.assertRaises(KeyError, msg="PydanticModel does not support field: non_existent"):
|
||||
get_field_meta_from_class(PydanticModel, "non_existent")
|
@ -1,3 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 7 15:04:35 UTC 2025 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
|
||||
|
||||
- Update to 0.11.0
|
||||
* Removed functions deprecated in 0.5.0: (#93)
|
||||
- `itemadapter.utils.is_attrs_instance()`
|
||||
- `itemadapter.utils.is_dataclass_instance()`
|
||||
- `itemadapter.utils.is_pydantic_instance()`
|
||||
- `itemadapter.utils.is_scrapy_item()`
|
||||
* Added support for Pydantic 2 (#91).
|
||||
* Added `__all__` to the top-level module to improve type checks (#90).
|
||||
* Improved `pre-commit` and CI configuration (#91), (#92).
|
||||
- from version 0.10.0
|
||||
* Dropped Python 3.8 support, added official Python
|
||||
3.13 and PyPy 3.10 support (#79), (#87).
|
||||
* Fixed the typing check when run with Scrapy 2.12.0+ (#88).
|
||||
* Fixed `MANIFEST.in` that was missing some files (#84).
|
||||
* Enabled `pre-commit` (#85).
|
||||
- Drop pydantic2.patch, fixed upstream
|
||||
- Set BuildArch to noarch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue May 14 07:56:28 UTC 2024 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-itemadapter
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
# Copyright (c) 2016, Martin Hauke <mardnh@gmx.de>
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
@ -27,14 +27,12 @@
|
||||
%endif
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-itemadapter%{psuffix}
|
||||
Version: 0.9.0
|
||||
Version: 0.11.0
|
||||
Release: 0
|
||||
Summary: Wrapper for data container objects
|
||||
License: BSD-3-Clause
|
||||
URL: https://github.com/scrapy/itemadapter
|
||||
Source: https://github.com/scrapy/itemadapter/archive/v%{version}.tar.gz#/itemadapter-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM pydantic2.patch gh#scrapy/itemadapter#76
|
||||
Patch0: pydantic2.patch
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools >= 40.5.0}
|
||||
BuildRequires: %{python_module wheel}
|
||||
@ -47,6 +45,7 @@ BuildRequires: %{python_module itemadapter >= %{version}}
|
||||
BuildRequires: %{python_module pydantic}
|
||||
BuildRequires: %{python_module pytest >= 5.4}
|
||||
%endif
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
|
Loading…
x
Reference in New Issue
Block a user