public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Filipe Rosset <rosset.filipe@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python-itemadapter] rawhide: Support Scrapy 2.17 unsorted fields
Date: Tue, 28 Jul 2026 02:51:58 GMT	[thread overview]
Message-ID: <178520711821.1.531905365525666830.rpms-python-itemadapter-0df2ca8ae22b@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/python-itemadapter
            Branch : rawhide
            Commit : 0df2ca8ae22b41faabaf7cd3ca5b6af04c60fbe4
            Author : Filipe Rosset <rosset.filipe@gmail.com>
            Date   : 2026-07-27T23:44:42-03:00
            Stats  : +135/-2 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-itemadapter/c/0df2ca8ae22b41faabaf7cd3ca5b6af04c60fbe4?branch=rawhide

            Log:
            Support Scrapy 2.17 unsorted fields

Resolves: rhbz#2504534

---
diff --git a/7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e.patch b/7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e.patch
new file mode 100644
index 0000000..2d4788f
--- /dev/null
+++ b/7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e.patch
@@ -0,0 +1,127 @@
+From 7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e Mon Sep 17 00:00:00 2001
+From: Andrey Rakhmatullin <wrar@wrar.name>
+Date: Fri, 24 Jul 2026 10:31:46 +0500
+Subject: [PATCH] Support Scrapy 2.17 unsorted fields. (#119)
+
+---
+ pyproject.toml        |  2 ++
+ tests/test_adapter.py | 72 +++++++++++++++++++++++--------------------
+ 2 files changed, 40 insertions(+), 34 deletions(-)
+
+diff --git a/pyproject.toml b/pyproject.toml
+index d1b24af..363a79f 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -253,6 +253,8 @@ ignore = [
+     "RUF012",
+     # Use of `assert` detected
+     "S101",
++    # Yoda condition detected
++    "SIM300",
+ ]
+ 
+ [tool.ruff.lint.isort]
+diff --git a/tests/test_adapter.py b/tests/test_adapter.py
+index 38130fc..734e40c 100644
+--- a/tests/test_adapter.py
++++ b/tests/test_adapter.py
+@@ -5,6 +5,7 @@
+ from types import MappingProxyType
+ 
+ import pytest
++from packaging.version import Version
+ 
+ from itemadapter.adapter import ItemAdapter, PydanticAdapter
+ from tests import (
+@@ -38,6 +39,13 @@
+ )
+ from tests.test_json_schema import check_schemas
+ 
++try:
++    import scrapy
++
++    SCRAPY_VERSION = Version(scrapy.__version__)
++except ImportError:
++    SCRAPY_VERSION = None
++
+ 
+ class ItemAdapterReprTestCase(unittest.TestCase):
+     def test_repr_dict(self):
+@@ -338,6 +346,35 @@ def test_field_names_from_class(self):
+     },
+ }
+ 
++_SCRAPY_JSON_SCHEMA_PROPERTIES = {
++    **NonDictTestMixin.expected_json_schema["properties"],
++    # Title is set through json_schema_extra, so it comes first.
++    "name": {"title": "Name", "type": "string", "description": "Display name"},
++    "nested": _SCRAPY_NESTED_JSON_SCHEMA,
++    "nested_list": {
++        "type": "array",
++        "items": _SCRAPY_NESTED_JSON_SCHEMA,
++    },
++    "nested_dict": {
++        "type": "object",
++        "additionalProperties": _SCRAPY_NESTED_JSON_SCHEMA,
++    },
++    "nested_dict_list": {
++        "type": "array",
++        "items": {
++            "type": "object",
++            "additionalProperties": _SCRAPY_NESTED_JSON_SCHEMA,
++        },
++    },
++    # No type, since none was specified in json_schema_extra.
++    "produced": {},
++}
++
++if SCRAPY_VERSION is not None and SCRAPY_VERSION < Version("2.17"):
++    # Scrapy < 2.17 sorts item fields alphabetically.
++    # https://github.com/scrapy/scrapy/issues/7015
++    _SCRAPY_JSON_SCHEMA_PROPERTIES = dict(sorted(_SCRAPY_JSON_SCHEMA_PROPERTIES.items()))
++
+ 
+ class ScrapySubclassedItemTestCase(NonDictTestMixin, unittest.TestCase):
+     item_class = ScrapySubclassedItem
+@@ -349,40 +386,7 @@ class ScrapySubclassedItemTestCase(NonDictTestMixin, unittest.TestCase):
+         "llmHint": "Hi model!",
+         "type": "object",
+         "additionalProperties": False,
+-        "properties": {
+-            **{
+-                k: NonDictTestMixin.expected_json_schema["properties"][k]
+-                for k in sorted(NonDictTestMixin.expected_json_schema["properties"])
+-            },
+-            # Different order since stuff defined in json_schema_extra comes
+-            # first.
+-            "name": {
+-                "title": "Name",
+-                "type": "string",
+-                "description": "Display name",
+-            },
+-            "nested": _SCRAPY_NESTED_JSON_SCHEMA,
+-            "nested_list": {
+-                "type": "array",
+-                "items": _SCRAPY_NESTED_JSON_SCHEMA,
+-            },
+-            "nested_dict": {
+-                "type": "object",
+-                "additionalProperties": _SCRAPY_NESTED_JSON_SCHEMA,
+-            },
+-            "nested_dict_list": {
+-                "type": "array",
+-                "items": {
+-                    "type": "object",
+-                    "additionalProperties": _SCRAPY_NESTED_JSON_SCHEMA,
+-                },
+-            },
+-            # No type, since none was specified in json_schema_extra.
+-            "produced": {},
+-            # value comes last due to Scrapy items sorting fields
+-            # alphabetically. https://github.com/scrapy/scrapy/issues/7015
+-            "value": NonDictTestMixin.expected_json_schema["properties"]["value"],
+-        },
++        "properties": _SCRAPY_JSON_SCHEMA_PROPERTIES,
+     }
+ 
+     def test_get_value_keyerror_item_dict(self):

diff --git a/python-itemadapter.spec b/python-itemadapter.spec
index 447e655..89582e1 100644
--- a/python-itemadapter.spec
+++ b/python-itemadapter.spec
@@ -3,6 +3,7 @@
 The ItemAdapter class is a wrapper for data container objects,
 providing a common interface to handle objects of different
 types in an uniform manner, regardless of their underlying implementation.}
+
 Name:		python-itemadapter
 Version:	0.13.1
 Release:	%autorelease
@@ -12,8 +13,12 @@ License:	BSD-3-Clause
 URL:		https://github.com/scrapy/itemadapter
 Source0:	%{pypi_source %pkg_name}
 
-BuildArch:	noarch
+# Upstream commit 7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e:
+# "Support Scrapy 2.17 unsorted fields" (PR #119)
+# https://github.com/scrapy/itemadapter/commit/7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e
+Patch:		7cfd6d6b0cf133d4ba188e3f25b940c50c402b2e.patch
 
+BuildArch:	noarch
 
 %description
 %{desc}
@@ -21,6 +26,7 @@ BuildArch:	noarch
 %package -n python3-%{pkg_name}
 Summary:	%{summary}
 
+BuildRequires:	pyproject-rpm-macros
 BuildRequires:	python3-devel
 
 
@@ -29,7 +35,7 @@ BuildRequires:	python3-devel
 
 
 %prep
-%autosetup -n %{pkg_name}-%{version}
+%autosetup -p1 -n %{pkg_name}-%{version}
 
 %generate_buildrequires
 %pyproject_buildrequires -t -x attrs,pydantic,scrapy

                 reply	other threads:[~2026-07-28  2:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178520711821.1.531905365525666830.rpms-python-itemadapter-0df2ca8ae22b@fedoraproject.org \
    --to=rosset.filipe@gmail.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox