internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Drop Python 3.5 support
Python 3.5 reaches end of life September 2020

https://devguide.python.org/#status-of-python-branches
https://www.python.org/downloads/release/python-3510/

Django 2.2 still supports Python 3.5 however I would recommend we drop it for the upcoming major version.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -81,7 +81,6 @@ def get_package_data(package):
         'Operating System :: OS Independent',
         'Programming Language :: Python',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: 3.7',
         'Programming Language :: Python :: 3.8',
@@ -99,6 +98,6 @@ def get_package_data(package):
         'django-filter': ['django-filter>=2.0']
     },
     setup_requires=wheel,
-    python_requires=">=3.5",
+    python_requires=">=3.6",
     zip_safe=False,
 )


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Add support for Python 3.9
As of https://github.com/encode/django-rest-framework/pull/7517 DRF already supports Python 3.9 so we can do to.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -84,6 +84,7 @@ def get_package_data(package):
         'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: 3.7',
         'Programming Language :: Python :: 3.8',
+        'Programming Language :: Python :: 3.9',
         'Topic :: Internet :: WWW/HTTP',
         'Topic :: Software Development :: Libraries :: Application Frameworks',
         'Topic :: Software Development :: Libraries :: Python Modules',


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Django 3.2 compatibility
Django 3.2 is now out, but we are currently blocked on upgrading to it due to djangorestframework-jsonapi specifically disallows that and newer versions as dependencies:
https://github.com/django-json-api/django-rest-framework-json-api/blob/0892e3a8a4dbad9630d70e2b78e18b242a8b057d/setup.py#L101

I couldn't find any other issues related to this so thought I would create one.

Are there any specific concerns with loosening the version constraint so users of this library also can upgrade to Django 3.2?


Discussion:
We want to specify each supported release of Django or other dependencies to make sure it actually works by running the test suite through it. See for instance #822 where Django 3.1 had been added and quite a bit of changes were needed.

Currently DRF has released a version which officially supports Django 3.2. This said I would be fine adding Django 3.2 support in DJA before DRF has a new release as long as the test suite runs through.

PR is welcome.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ def get_package_data(package):
     install_requires=[
         "inflection>=0.3.0",
         "djangorestframework>=3.12,<3.13",
-        "django>=2.2,<3.2",
+        "django>=2.2,<3.3",
     ],
     extras_require={
         "django-polymorphic": ["django-polymorphic>=2.0"],


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -10,7 +10,7 @@ jobs:
       fail-fast: false
       matrix:
         python-version: ["3.6", "3.7", "3.8", "3.9"]
-        django: ["2.2", "3.0", "3.1"]
+        django: ["2.2", "3.0", "3.1", "3.2"]
         django-rest-framework: ["3.12", "master"]
     env:
       PYTHON: ${{ matrix.python-version }}
Repository: django-json-api/django-rest-framework-json-api

Issue:
Apply tags defined in OAS schema
In https://github.com/encode/django-rest-framework/pull/7184, tags support was added to DRF.
It can be viewed here:
https://github.com/encode/django-rest-framework/pull/7184/files#diff-99d3943485b50b323271fe5399dab8b2c778f42cbc0749b0f702e4cab0a81b2cR107

DJA doesn't yet have this added.


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/schemas/openapi.py b/rest_framework_json_api/schemas/openapi.py
--- a/rest_framework_json_api/schemas/openapi.py
+++ b/rest_framework_json_api/schemas/openapi.py
@@ -427,6 +427,7 @@ def get_operation(self, path, method):
             parameters += self.get_pagination_parameters(path, method)
             parameters += self.get_filter_parameters(path, method)
         operation["parameters"] = parameters
+        operation["tags"] = self.get_tags(path, method)
 
         # get request and response code schemas
         if method == "GET":


Test patch:
diff --git a/example/tests/snapshots/snap_test_openapi.py b/example/tests/snapshots/snap_test_openapi.py
--- a/example/tests/snapshots/snap_test_openapi.py
+++ b/example/tests/snapshots/snap_test_openapi.py
@@ -121,7 +121,10 @@
       },
       "description": "not found"
     }
-  }
+  },
+  "tags": [
+    "authors"
+  ]
 }"""
 
 snapshots[
@@ -227,7 +230,10 @@
       },
       "description": "not found"
     }
-  }
+  },
+  "tags": [
+    "authors"
+  ]
 }"""
 
 snapshots[
@@ -411,7 +417,10 @@
       },
       "description": "[Conflict](https://jsonapi.org/format/#crud-creating-responses-409)"
     }
-  }
+  },
+  "tags": [
+    "authors"
+  ]
 }"""
 
 snapshots[
@@ -589,7 +598,10 @@
       },
       "description": "[Conflict]([Conflict](https://jsonapi.org/format/#crud-updating-responses-409)"
     }
-  }
+  },
+  "tags": [
+    "authors"
+  ]
 }"""
 
 snapshots[
@@ -652,5 +664,8 @@
       },
       "description": "[Resource does not exist](https://jsonapi.org/format/#crud-deleting-responses-404)"
     }
-  }
+  },
+  "tags": [
+    "authors"
+  ]
 }"""
Repository: django-json-api/django-rest-framework-json-api

Issue:
Release needed for Django 3.2 Update
Hello,

I see that there was a change to allow Django 3.2, but no new release has happened. This is preventing us from upgrading, could we get a new version released?

Thank you!


Discussion:
There are some regressions introduced in version 4.1.0 which I would like to address first before a new release. See PR in progress #904 #900 #897 which need to be cleaned up first though before being merged. I hope to get some time to get around those soon. Once this is ready there will be a new release.

Resolving patch:
diff --git a/rest_framework_json_api/__init__.py b/rest_framework_json_api/__init__.py
--- a/rest_framework_json_api/__init__.py
+++ b/rest_framework_json_api/__init__.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 __title__ = "djangorestframework-jsonapi"
-__version__ = "4.1.0"
+__version__ = "4.2.0"
 __author__ = ""
 __license__ = "BSD"
 __copyright__ = ""


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
document classes and overrides used in the example app
[Usage documentation](https://django-rest-framework-json-api.readthedocs.io/en/stable/usage.html) and the example app are not consistent with each other. There are several classes used in the example that lack proper usage documentation and docstrings. 

Documentation updates (or changes to use documented classes and deprecation of undocumented classes) are needed for the following:

- [x] `relations.SerializerMethodResourceRelatedField`
- [x] `relations.SerializerMethodHyperlinkedRelatedField`
- [ ] `get_queryset()` and `get_object()` implementation differs between example views and usage doc.

There may be others; please update this list if you see them.


Discussion:

Resolving patch:
diff --git a/example/views.py b/example/views.py
--- a/example/views.py
+++ b/example/views.py
@@ -243,11 +243,13 @@ class CommentViewSet(ModelViewSet):
     }
 
     def get_queryset(self, *args, **kwargs):
+        queryset = super().get_queryset()
+
         entry_pk = self.kwargs.get("entry_pk", None)
         if entry_pk is not None:
-            return self.queryset.filter(entry_id=entry_pk)
+            queryset = queryset.filter(entry_id=entry_pk)
 
-        return super(CommentViewSet, self).get_queryset()
+        return queryset
 
 
 class CompanyViewset(ModelViewSet):


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Allow meta as attribute name
It doesn't seem that the json api spec disallows meta as an attribute name but currently an exception is raised when such naming is used in DJA.

See example PR https://github.com/django-json-api/django-rest-framework-json-api/pull/654 how to reproduce it.


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -184,6 +184,25 @@ def __repr__(self):
 
 
 class SerializerMetaclass(SerializerMetaclass):
+
+    _reserved_field_names = {"meta", "results"}
+
+    @classmethod
+    def _get_declared_fields(cls, bases, attrs):
+        fields = super()._get_declared_fields(bases, attrs)
+
+        found_reserved_field_names = cls._reserved_field_names.intersection(
+            fields.keys()
+        )
+        if found_reserved_field_names:
+            raise AttributeError(
+                f"Serializer class {attrs['__module__']}.{attrs['__qualname__']} uses "
+                f"following reserved field name(s) which is not allowed: "
+                f"{', '.join(sorted(found_reserved_field_names))}"
+            )
+
+        return fields
+
     def __new__(cls, name, bases, attrs):
         serializer = super().__new__(cls, name, bases, attrs)
 


Test patch:
diff --git a/tests/test_serializers.py b/tests/test_serializers.py
--- a/tests/test_serializers.py
+++ b/tests/test_serializers.py
@@ -1,3 +1,4 @@
+import pytest
 from django.db import models
 
 from rest_framework_json_api import serializers
@@ -33,3 +34,17 @@ class Meta:
     }
 
     assert included_serializers == expected_included_serializers
+
+
+def test_reserved_field_names():
+    with pytest.raises(AttributeError) as e:
+
+        class ReservedFieldNamesSerializer(serializers.Serializer):
+            meta = serializers.CharField()
+            results = serializers.CharField()
+
+    assert str(e.value) == (
+        "Serializer class tests.test_serializers.test_reserved_field_names.<locals>."
+        "ReservedFieldNamesSerializer uses following reserved field name(s) which is "
+        "not allowed: meta, results"
+    )
Repository: django-json-api/django-rest-framework-json-api

Issue:
Add support for Django 4.0
## Description of the Bug Report

Django 4.0a1 has been [released](https://www.djangoproject.com/weblog/2021/sep/21/django-40-alpha-1-released/). As it is marked as feature freeze we can also add it to our test suite.

DRF has also already [added](https://github.com/encode/django-rest-framework/pull/8178) it. As a reference to implement this have a look at #908

## Checklist

- [x] Certain that this is a bug (if unsure or you have a question use [discussions](https://github.com/django-json-api/django-rest-framework-json-api/discussions) instead)
- [x] Code snippet or unit test added to reproduce bug



Discussion:

Resolving patch:
diff --git a/example/settings/dev.py b/example/settings/dev.py
--- a/example/settings/dev.py
+++ b/example/settings/dev.py
@@ -5,6 +5,7 @@
 
 MEDIA_ROOT = os.path.normcase(os.path.dirname(os.path.abspath(__file__)))
 MEDIA_URL = "/media/"
+USE_TZ = False
 
 DATABASE_ENGINE = "sqlite3"
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -97,7 +97,7 @@ def get_package_data(package):
     install_requires=[
         "inflection>=0.3.0",
         "djangorestframework>=3.12,<3.13",
-        "django>=2.2,<3.3",
+        "django>=2.2,<4.1",
     ],
     extras_require={
         "django-polymorphic": ["django-polymorphic>=2.0"],


Test patch:
diff --git a/example/urls_test.py b/example/urls_test.py
--- a/example/urls_test.py
+++ b/example/urls_test.py
@@ -1,4 +1,4 @@
-from django.conf.urls import re_path
+from django.urls import re_path
 from rest_framework import routers
 
 from .api.resources.identity import GenericIdentity, Identity
diff --git a/tests/test_relations.py b/tests/test_relations.py
--- a/tests/test_relations.py
+++ b/tests/test_relations.py
@@ -1,5 +1,5 @@
 import pytest
-from django.conf.urls import re_path
+from django.urls import re_path
 from rest_framework import status
 from rest_framework.fields import SkipField
 from rest_framework.routers import SimpleRouter
Repository: django-json-api/django-rest-framework-json-api

Issue:
Add support for Python 3.10
## Description of the Bug Report

Python 3.10 has been [released](https://www.python.org/downloads/release/python-3100/) and we should add support to DJA. See #846 as reference for implementation.

## Checklist

- [x] Certain that this is a bug (if unsure or you have a question use [discussions](https://github.com/django-json-api/django-rest-framework-json-api/discussions) instead)
- [x] Code snippet or unit test added to reproduce bug



Discussion:
I want to handle this one
Go for it.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,7 @@ def get_package_data(package):
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3.10",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Software Development :: Libraries :: Application Frameworks",
         "Topic :: Software Development :: Libraries :: Python Modules",


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -8,7 +8,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        python-version: ["3.6", "3.7", "3.8", "3.9"]
+        python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
     env:
       PYTHON: ${{ matrix.python-version }}
     steps:
Repository: modal-labs/modal-examples

Issue:
apply #556 manually
I manually applied the patch from #556. Not sure what's up with that PR


Discussion:

Resolving patch:
diff --git a/01_getting_started/hello_world.py b/01_getting_started/hello_world.py
--- a/01_getting_started/hello_world.py
+++ b/01_getting_started/hello_world.py
@@ -48,7 +48,7 @@ def f(i):
 #
 # Inside the `main()` function body, we are calling the function `f` in three ways:
 #
-# 1  As a simple local call, `f(1000)`
+# 1  As a simple local call, `f.local(1000)`
 # 2. As a simple *remote* call `f.remote(1000)`
 # 3. By mapping over the integers `0..19`
 


Test patch:
Repository: modal-labs/modal-examples

Issue:
remove duplicate webscraper example once #669 is merged



Discussion:

Resolving patch:
diff --git a/10_integrations/webscraper.py b/10_integrations/webscraper.py
--- a/10_integrations/webscraper.py
+++ b/10_integrations/webscraper.py
@@ -15,7 +15,7 @@
     "apt-get install -y software-properties-common",
     "apt-add-repository non-free",
     "apt-add-repository contrib",
-    "pip install playwright==1.30.0",
+    "pip install playwright==1.42.0",
     "playwright install-deps chromium",
     "playwright install chromium",
 )
diff --git a/misc/webscraper.py b/misc/webscraper.py
deleted file mode 100644
--- a/misc/webscraper.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# ---
-# runtimes: ["runc", "gvisor"]
-# ---
-import os
-
-import modal
-
-stub = modal.Stub("example-linkscraper")
-
-
-playwright_image = modal.Image.debian_slim(
-    python_version="3.10"
-).run_commands(  # Doesn't work with 3.11 yet
-    "apt-get update",
-    "apt-get install -y software-properties-common",
-    "apt-add-repository non-free",
-    "apt-add-repository contrib",
-    "pip install playwright==1.30.0",
-    "playwright install-deps chromium",
-    "playwright install chromium",
-)
-
-
-@stub.function(image=playwright_image)
-async def get_links(url: str) -> set[str]:
-    from playwright.async_api import async_playwright
-
-    async with async_playwright() as p:
-        browser = await p.chromium.launch()
-        page = await browser.new_page()
-        await page.goto(url)
-        links = await page.eval_on_selector_all(
-            "a[href]", "elements => elements.map(element => element.href)"
-        )
-        await browser.close()
-
-    return set(links)
-
-
-slack_sdk_image = modal.Image.debian_slim().pip_install("slack-sdk")
-
-
-@stub.function(
-    image=slack_sdk_image,
-    secrets=[modal.Secret.from_name("scraper-slack-secret")],
-)
-def bot_token_msg(channel, message):
-    import slack_sdk
-
-    print(f"Posting {message} to #{channel}")
-    client = slack_sdk.WebClient(token=os.environ["SLACK_BOT_TOKEN"])
-    client.chat_postMessage(channel=channel, text=message)
-
-
-@stub.function()
-def scrape():
-    links_of_interest = ["http://modal.com"]
-
-    for links in get_links.map(links_of_interest):
-        for link in links:
-            bot_token_msg.remote("scraped-links", link)
-
-
-@stub.function(schedule=modal.Period(days=1))
-def daily_scrape():
-    scrape.remote()
-
-
-@stub.local_entrypoint()
-def run():
-    scrape.remote()


Test patch:
Repository: ibis-project/ibis

Issue:
Tests that require connecting to Impala/HDFS should be opt-in
And fail if the connection fails, rather than skipping.



Discussion:
makes sense; opt-in via environment variable (and we can add some flags to `ibis.test`)

@laserson you want to handle this one?

yep


Resolving patch:
diff --git a/ibis/__init__.py b/ibis/__init__.py
--- a/ibis/__init__.py
+++ b/ibis/__init__.py
@@ -126,6 +126,6 @@ def test(include_e2e=False):
     ibis_dir, _ = os.path.split(ibis.__file__)
 
     args = ['--pyargs', ibis_dir]
-    if not include_e2e:
-        args.extend(['-m', 'not e2e'])
+    if include_e2e:
+        args.append('--e2e')
     pytest.main(args)


Test patch:
diff --git a/ibis/tests/conftest.py b/ibis/tests/conftest.py
new file mode 100644
--- /dev/null
+++ b/ibis/tests/conftest.py
@@ -0,0 +1,26 @@
+# Copyright 2015 Cloudera Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from pytest import skip
+
+
+def pytest_addoption(parser):
+    parser.addoption('--e2e', action='store_true', default=False,
+                     help='Enable the e2e (end-to-end) tests')
+
+
+def pytest_runtest_setup(item):
+    if getattr(item.obj, 'e2e', None):  # the test item is marked e2e
+        if not item.config.getvalue('e2e'): # but --e2e option not set
+            skip('e2e was not enabled')
diff --git a/ibis/tests/test_filesystems.py b/ibis/tests/test_filesystems.py
--- a/ibis/tests/test_filesystems.py
+++ b/ibis/tests/test_filesystems.py
@@ -19,6 +19,7 @@
 import shutil
 
 from hdfs import InsecureClient
+import pytest
 
 from ibis.filesystems import HDFS, WebHDFS
 from ibis.compat import unittest
@@ -26,6 +27,9 @@
 import ibis.util as util
 
 
+ENV = IbisTestEnv()
+
+
 class MockHDFS(HDFS):
 
     def __init__(self):
@@ -64,12 +68,12 @@ def test_find_any_file(self):
         result = self.con.find_any_file('/path')
         assert result == '/path/0.parq'
 
-
+@pytest.mark.e2e
 class TestHDFSE2E(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.ENV = IbisTestEnv()
+        cls.ENV = ENV
         cls.tmp_dir = pjoin(cls.ENV.tmp_dir, util.guid())
         cls.hdfs_client = InsecureClient(cls.ENV.hdfs_url)
         cls.hdfs = WebHDFS(cls.hdfs_client)
diff --git a/ibis/tests/test_impala_e2e.py b/ibis/tests/test_impala_e2e.py
--- a/ibis/tests/test_impala_e2e.py
+++ b/ibis/tests/test_impala_e2e.py
@@ -49,9 +49,7 @@ def connect(env, with_hdfs=True):
         return ibis.make_client(con)
 
 
-pytestmark = pytest.mark.e2e
-
-
+@pytest.mark.e2e
 class ImpalaE2E(object):
 
     @classmethod
Repository: ibis-project/ibis

Issue:
WebHDFS.write has trouble with StringIO/BytesIO types
It hangs for a while and then gives `ConnectionError: ('Connection aborted.', BadStatusLine("''",))`.  As a temporary workaround, I will get a string version of the data by calling `getvalue` before transmitting the data.  This shouldn't cause too many surprises, bc if the user wants to write a file, they can just specify the path.  But this should be fixed.  It appears the problem is in the python `requests` library.



Discussion:

Resolving patch:
diff --git a/ibis/filesystems.py b/ibis/filesystems.py
--- a/ibis/filesystems.py
+++ b/ibis/filesystems.py
@@ -327,11 +327,9 @@ def put(self, hdfs_path, resource, overwrite=False, verbose=None,
             else:
                 if verbose:
                     self.log('Writing buffer to HDFS {0}'.format(hdfs_path))
-                # TODO: eliminate the .getvalue() call to support general
-                # handle types
                 resource.seek(0)
-                self.client.write(hdfs_path, resource.read(),
-                                  overwrite=overwrite, **kwargs)
+                self.client.write(hdfs_path, resource, overwrite=overwrite,
+                                  **kwargs)
 
     @implements(HDFS.get)
     def get(self, hdfs_path, local_path, overwrite=False, verbose=None):


Test patch: