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

Issue:
Implement `Request.__repr__` to show useful information about the request
## Checklist

- [x] I have verified that that issue exists against the `master` branch of Django REST framework.
- [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- [x] This is not a usage question. (Those should be directed to the [discussion group](https://groups.google.com/forum/#!forum/django-rest-framework) instead.)
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](https://www.django-rest-framework.org/community/third-party-packages/#about-third-party-packages) where possible.)
- [x] I have reduced the issue to the simplest possible case.
- [ ] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

The path, for starters, would be useful.


Discussion:
The first thing to do on this issue would be to confirm:

* What the `__repr__` behavior of a standard Django request instance is.
* What the `__repr__` behavior of our Request instances currently is.
* Talk through what exact changes would be suggested.
> What the `__repr__` behavior of a standard Django request instance is.

`<WSGIRequest: GET '/foo'>`

> What the `__repr__` behavior of our Request instances currently is.

`<rest_framework.request.Request at 0x10f43dcd0>`



Resolving patch:
diff --git a/rest_framework/request.py b/rest_framework/request.py
--- a/rest_framework/request.py
+++ b/rest_framework/request.py
@@ -179,6 +179,13 @@ def __init__(self, request, parsers=None, authenticators=None,
             forced_auth = ForcedAuthentication(force_user, force_token)
             self.authenticators = (forced_auth,)
 
+    def __repr__(self):
+        return '<%s.%s: %s %r>' % (
+            self.__class__.__module__,
+            self.__class__.__name__,
+            self.method,
+            self.get_full_path())
+
     def _default_negotiator(self):
         return api_settings.DEFAULT_CONTENT_NEGOTIATION_CLASS()
 


Test patch:
diff --git a/tests/test_request.py b/tests/test_request.py
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -272,6 +272,12 @@ def test_default_secure_true(self):
 
 
 class TestHttpRequest(TestCase):
+    def test_repr(self):
+        http_request = factory.get('/path')
+        request = Request(http_request)
+
+        assert repr(request) == "<rest_framework.request.Request: GET '/path'>"
+
     def test_attribute_access_proxy(self):
         http_request = factory.get('/')
         request = Request(http_request)
Repository: encode/django-rest-framework

Issue:
"Action" button does not render in API if `app_name` is set
## Checklist

- [x] I have verified that that issue exists against the `master` branch of Django REST framework.
- [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- [x] This is not a usage question. (Those should be directed to the [discussion group](https://groups.google.com/forum/#!forum/django-rest-framework) instead.)
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](https://www.django-rest-framework.org/community/third-party-packages/#about-third-party-packages) where possible.)
- [x] I have reduced the issue to the simplest possible case.
- [ ] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

## Steps to reproduce

In `api_views.py`:

```python
class SomeViewSet(viewsets.ModelViewSet):
  queryset = ...
  serializer_class = ...

  @action(method=['POST'], detail=False, )
  def some_action(self, request):
    # ..
    return Response("Hi")
```

In `api_urls.py`:

```python
from rest_framework import routers
from . import api_views

router = routers.DefaultRouter()
router.register(r'some_link', api_views.SomeViewSet)
```

in `urls.py`: 

```python
from .api_urls import router

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include((router.urls, "api"))),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
]
```

## Expected behaviour
To see "Actions" button on http://127.0.0.1:8000/api/some_link/ page. 

## Actual behaviour

The button is not there.

## How to fix

Remove app name in `urlpaths`; however, this breaks `{% url ... %}` syntax in Django templates. 


Discussion:

Resolving patch:
diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py
--- a/rest_framework/viewsets.py
+++ b/rest_framework/viewsets.py
@@ -150,6 +150,11 @@ def reverse_action(self, url_name, *args, **kwargs):
         Reverse the action for the given `url_name`.
         """
         url_name = '%s-%s' % (self.basename, url_name)
+        namespace = None
+        if self.request and self.request.resolver_match:
+            namespace = self.request.resolver_match.namespace
+        if namespace:
+            url_name = namespace + ':' + url_name
         kwargs.setdefault('request', self.request)
 
         return reverse(url_name, *args, **kwargs)


Test patch:
Repository: encode/django-rest-framework

Issue:
Implement ModelSerializer.__class_getitem__
To allow type checking efforts to properly type the methods of `ModelSerializer` it needs to be made generic with regards to the model it serializes. Since django-rest-framework has chosen to not own any annotations themselves the only way to achieve that will be to implement `__class_getitem__`. Stub implementors can then make the class generic and calling `ModelSerializer[Author]` will not yield subscriptability errors at runtime.

Note that this is the unfortunate direction [Django has chosen as well](https://github.com/django/django/commit/578c03b276e435bcd3ce9eb17b81e85135c2d3f3).

[This is the relevant issue in djangorestframework-stubs](https://github.com/typeddjango/djangorestframework-stubs/issues/71) for reference.

[This is the relevant Python docs on generic classes.](https://docs.python.org/3/library/typing.html#user-defined-generic-types)


Discussion:

Resolving patch:
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -121,6 +121,10 @@ def __new__(cls, *args, **kwargs):
             return cls.many_init(*args, **kwargs)
         return super().__new__(cls, *args, **kwargs)
 
+    # Allow type checkers to make serializers generic.
+    def __class_getitem__(cls, *args, **kwargs):
+        return cls
+
     @classmethod
     def many_init(cls, *args, **kwargs):
         """


Test patch:
diff --git a/tests/test_serializer.py b/tests/test_serializer.py
--- a/tests/test_serializer.py
+++ b/tests/test_serializer.py
@@ -1,6 +1,7 @@
 import inspect
 import pickle
 import re
+import sys
 from collections import ChainMap
 from collections.abc import Mapping
 
@@ -204,6 +205,13 @@ class ExampleSerializer(serializers.Serializer):
                 exceptions.ErrorDetail(string='Raised error', code='invalid')
             ]}
 
+    @pytest.mark.skipif(
+        sys.version_info < (3, 7),
+        reason="subscriptable classes requires Python 3.7 or higher",
+    )
+    def test_serializer_is_subscriptable(self):
+        assert serializers.Serializer is serializers.Serializer["foo"]
+
 
 class TestValidateMethod:
     def test_non_field_error_validate_method(self):
diff --git a/tests/test_serializer_lists.py b/tests/test_serializer_lists.py
--- a/tests/test_serializer_lists.py
+++ b/tests/test_serializer_lists.py
@@ -1,3 +1,5 @@
+import sys
+
 import pytest
 from django.http import QueryDict
 from django.utils.datastructures import MultiValueDict
@@ -55,6 +57,13 @@ def test_validate_html_input(self):
         assert serializer.is_valid()
         assert serializer.validated_data == expected_output
 
+    @pytest.mark.skipif(
+        sys.version_info < (3, 7),
+        reason="subscriptable classes requires Python 3.7 or higher",
+    )
+    def test_list_serializer_is_subscriptable(self):
+        assert serializers.ListSerializer is serializers.ListSerializer["foo"]
+
 
 class TestListSerializerContainingNestedSerializer:
     """
Repository: encode/django-rest-framework

Issue:
Passing None for the middleware get_response argument is deprecated.
Looking at the travis builds on master in addition to the `url()` deprecation there is also a few failing with this warning. 

```
  /home/travis/build/encode/django-rest-framework/rest_framework/authentication.py:139: RemovedInDjango40Warning: Passing None for the middleware get_response argument is deprecated.
    check = CSRFCheck()
```

I couldn't see anything raised already but my search skills for `url()` let me down somewhat 🙈 


Discussion:

Resolving patch:
diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py
--- a/rest_framework/authentication.py
+++ b/rest_framework/authentication.py
@@ -136,7 +136,10 @@ def enforce_csrf(self, request):
         """
         Enforce CSRF validation for session based authentication.
         """
-        check = CSRFCheck()
+        def dummy_get_response(request):  # pragma: no cover
+            return None
+
+        check = CSRFCheck(dummy_get_response)
         # populates request.META['CSRF_COOKIE'], which is used in process_view()
         check.process_request(request)
         reason = check.process_view(request, None, (), {})


Test patch:
diff --git a/tests/test_request.py b/tests/test_request.py
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -205,8 +205,12 @@ def setUp(self):
         # available to login and logout functions
         self.wrapped_request = factory.get('/')
         self.request = Request(self.wrapped_request)
-        SessionMiddleware().process_request(self.wrapped_request)
-        AuthenticationMiddleware().process_request(self.wrapped_request)
+
+        def dummy_get_response(request):  # pragma: no cover
+            return None
+
+        SessionMiddleware(dummy_get_response).process_request(self.wrapped_request)
+        AuthenticationMiddleware(dummy_get_response).process_request(self.wrapped_request)
 
         User.objects.create_user('ringo', 'starr@thebeatles.com', 'yellow')
         self.user = authenticate(username='ringo', password='yellow')
Repository: encode/django-rest-framework

Issue:
Missing migration for TokenProxy in 3.12 release
## Checklist

- [x] I have verified that that issue exists against the `master` branch of Django REST framework.
- [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- [x] This is not a usage question. (Those should be directed to the [discussion group](https://groups.google.com/forum/#!forum/django-rest-framework) instead.)
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](https://www.django-rest-framework.org/community/third-party-packages/#about-third-party-packages) where possible.)
- [x] I have reduced the issue to the simplest possible case.
- [ ] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

## Steps to reproduce
* Look at https://github.com/encode/django-rest-framework/tree/3.12.0/rest_framework/authtoken/migrations to see that there is no migration introducing the `TokenProxy` model.
* Alternatively (the way I found it): Have a django project which uses the rest-framework complain on startup that a migration is missing for the `TokenProxy` model.
## Expected behavior
An existing migration for the `TokenProxy` model.
## Actual behavior
No migration for the `TokenProxy` model.


Discussion:

Resolving patch:
diff --git a/rest_framework/authtoken/migrations/0003_tokenproxy.py b/rest_framework/authtoken/migrations/0003_tokenproxy.py
new file mode 100644
--- /dev/null
+++ b/rest_framework/authtoken/migrations/0003_tokenproxy.py
@@ -0,0 +1,25 @@
+# Generated by Django 3.1.1 on 2020-09-28 09:34
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('authtoken', '0002_auto_20160226_1747'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='TokenProxy',
+            fields=[
+            ],
+            options={
+                'verbose_name': 'token',
+                'proxy': True,
+                'indexes': [],
+                'constraints': [],
+            },
+            bases=('authtoken.token',),
+        ),
+    ]


Test patch:
Repository: encode/django-rest-framework

Issue:
Add support to Python 3.11
## Checklist

- [ ] Raised initially as discussion #...
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](https://www.django-rest-framework.org/community/third-party-packages/#about-third-party-packages) where possible.)
- [x] I have reduced the issue to the simplest possible case.

Add support to Python 3.11 in tests, docs and classifier.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -104,6 +104,7 @@ def get_version(package):
         'Programming Language :: Python :: 3.8',
         'Programming Language :: Python :: 3.9',
         'Programming Language :: Python :: 3.10',
+        'Programming Language :: Python :: 3.11',
         'Programming Language :: Python :: 3 :: Only',
         'Topic :: Internet :: WWW/HTTP',
     ],


Test patch:
Repository: encode/django-rest-framework

Issue:
rest_framework.urls doesn't work with LogoutView in Django 5.0
In Django 5.0, GET request for logout was removed (only POST supported now) and it seems like in DRF we still do GET request to the endpoint. 

# https://docs.djangoproject.com/en/5.0/releases/5.0/
- Support for logging out via GET requests in the django.contrib.auth.views.LogoutView and django.contrib.auth.views.logout_then_login() is removed.


Discussion:
can you share the traceback as well please?

Resolving patch:
diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py
--- a/rest_framework/templatetags/rest_framework.py
+++ b/rest_framework/templatetags/rest_framework.py
@@ -119,7 +119,7 @@ def optional_docs_login(request):
 
 
 @register.simple_tag
-def optional_logout(request, user):
+def optional_logout(request, user, csrf_token):
     """
     Include a logout snippet if REST framework's logout view is in the URLconf.
     """
@@ -135,11 +135,16 @@ def optional_logout(request, user):
             <b class="caret"></b>
         </a>
         <ul class="dropdown-menu">
-            <li><a href='{href}?next={next}'>Log out</a></li>
+            <form id="logoutForm" method="post" action="{href}?next={next}">
+                <input type="hidden" name="csrfmiddlewaretoken" value="{csrf_token}">
+            </form>
+            <li>
+                <a href="#" onclick='document.getElementById("logoutForm").submit()'>Log out</a>
+            </li>
         </ul>
     </li>"""
-    snippet = format_html(snippet, user=escape(user), href=logout_url, next=escape(request.path))
-
+    snippet = format_html(snippet, user=escape(user), href=logout_url,
+                          next=escape(request.path), csrf_token=csrf_token)
     return mark_safe(snippet)
 
 


Test patch:
diff --git a/tests/browsable_api/test_browsable_api.py b/tests/browsable_api/test_browsable_api.py
--- a/tests/browsable_api/test_browsable_api.py
+++ b/tests/browsable_api/test_browsable_api.py
@@ -65,6 +65,12 @@ def test_login_shown_when_logged_out(self):
         content = response.content.decode()
         assert '>Log in<' in content
 
+    def test_dropdown_contains_logout_form(self):
+        self.client.login(username=self.username, password=self.password)
+        response = self.client.get('/')
+        content = response.content.decode()
+        assert '<form id="logoutForm" method="post" action="/auth/logout/?next=/">' in content
+
 
 @override_settings(ROOT_URLCONF='tests.browsable_api.no_auth_urls')
 class NoDropdownWithoutAuthTests(TestCase):
Repository: encode/django-rest-framework

Issue:
_delegate_text was removed in Django 5.
## Checklist

- [ ] Raised initially as discussion #...
- [x] This cannot be dealt with as a third party library. (We prefer new functionality to be [in the form of third party libraries](https://www.django-rest-framework.org/community/third-party-packages/#about-third-party-packages) where possible.)
- [ ] I have reduced the issue to the simplest possible case.

https://github.com/encode/django-rest-framework/blob/4c7c693f1555689cda88eb59a4353db69aa6f5b1/rest_framework/utils/representation.py#L30-L31

force_str has a built in parameter called `strings_only`.  So the version number should be checked, and then if it is django 5, it should do the following instead of using delegate_text.

```python
        value = force_str(value, strings_only=True)
```



Discussion:
I'd make a pull request, if I had time, but you might get to this before I can, since it is relatively simple.
would be helpful If you could come with a PR

Resolving patch:
diff --git a/rest_framework/utils/representation.py b/rest_framework/utils/representation.py
--- a/rest_framework/utils/representation.py
+++ b/rest_framework/utils/representation.py
@@ -27,8 +27,8 @@ def smart_repr(value):
     if isinstance(value, models.Manager):
         return manager_repr(value)
 
-    if isinstance(value, Promise) and value._delegate_text:
-        value = force_str(value)
+    if isinstance(value, Promise):
+        value = force_str(value, strings_only=True)
 
     value = repr(value)
 


Test patch:
Repository: encode/django-rest-framework

Issue:
Version 3.15.1
This is a patch release dealing with a number of unforeseen issues in 3.15.0.

Please see https://github.com/encode/django-rest-framework/discussions/9270 for discussion on the project management, and ensuring we're able to get into a much more carefully considered release process for future releases.

(In brief: The project should broadly just be tracking Django versions, and dealing with required security fixes. We need a much higher bar to accepting contributions, and need some clear guidelines to help us manage that process with as little noise and churn as possible.)

---

*The following change has been fixed*...

- [x] #9308 

---

*The following changes have all been reverted, for the time being*...

- [x] #9319 - Resolved via #9327
- [x] #9317 - Resolved via #9326
- [x] #9310 - Resolved via #9333
- [x] #9306 - Resolved via #9327
- [x] #9299 - Resolved via #9332
- [x] #9295 - Resolved via #9330
- [x] #9300 - Resolved via #9301
- [x] #9334 - Resolved via #9335



Discussion:
Consider adding #9334

Resolving patch:
diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py
--- a/rest_framework/__init__.py
+++ b/rest_framework/__init__.py
@@ -10,7 +10,7 @@
 import django
 
 __title__ = 'Django REST framework'
-__version__ = '3.15.0'
+__version__ = '3.15.1'
 __author__ = 'Tom Christie'
 __license__ = 'BSD 3-Clause'
 __copyright__ = 'Copyright 2011-2023 Encode OSS Ltd'


Test patch:
Repository: microsoft/promptflow

Issue:
[BUG] Fallback to DefaultAzureCredential isn't compatible with AzureDeveloperCliCredential
**Describe the bug**

PromptFlow currently falls back to using DefaultAzureCredential and fetching a token for the Oauth 1.0 audience. That is not compatible with all credentials in the chain, specifically, the AzureDeveloperCliCredential which is Oauth 2.0 only. This PR changes the audience value to the correct scope value, and renames variables accordingly.


**How To Reproduce the bug**
Steps to reproduce the behavior, how frequent can you experience the bug:
1. Run `azd auth login` and DONT login to Azure CLI
2. Run ai-rag-chat-evaluator or other sample code that does *not* specify a credential when using the evaluators/evaluate function


PR incoming!


Discussion:

Resolving patch:
diff --git a/src/promptflow-core/promptflow/_core/token_provider.py b/src/promptflow-core/promptflow/_core/token_provider.py
--- a/src/promptflow-core/promptflow/_core/token_provider.py
+++ b/src/promptflow-core/promptflow/_core/token_provider.py
@@ -4,8 +4,8 @@
 from promptflow._utils.credential_utils import get_default_azure_credential
 
 
-# to access azure ai services, we need to get the token with this audience
-COGNITIVE_AUDIENCE = "https://cognitiveservices.azure.com/"
+# to access azure ai services, we need to get the token with this scope
+COGNITIVE_SCOPE = "https://cognitiveservices.azure.com/.default"
 
 
 class TokenProviderABC(ABC):
@@ -48,5 +48,5 @@ def _init_instance(self):
             )
 
     def get_token(self):
-        audience = COGNITIVE_AUDIENCE
-        return self.credential.get_token(audience).token
+        scope = COGNITIVE_SCOPE
+        return self.credential.get_token(scope).token


Test patch:
Repository: docarray/docarray

Issue:
fix: fix tags type after pydantic model



Discussion:

Resolving patch:
diff --git a/docarray/document/pydantic_model.py b/docarray/document/pydantic_model.py
--- a/docarray/document/pydantic_model.py
+++ b/docarray/document/pydantic_model.py
@@ -7,7 +7,8 @@
 if TYPE_CHECKING:
     from ..types import ArrayType
 
-_ProtoValueType = Optional[Union[str, bool, float]]
+# this order must be preserved: https://pydantic-docs.helpmanual.io/usage/types/#unions
+_ProtoValueType = Optional[Union[bool, float, str]]
 _StructValueType = Union[
     _ProtoValueType, List[_ProtoValueType], Dict[str, _ProtoValueType]
 ]


Test patch:
diff --git a/tests/__init__.py b/tests/__init__.py
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -20,7 +20,7 @@ def random_docs(
 
         d = Document(id=doc_id)
         d.text = text
-        d.tags['id'] = doc_id
+        d.tags['id'] = f'myself id is: {doc_id}'
         if embedding:
             if sparse_embedding:
                 from scipy.sparse import coo_matrix
@@ -42,8 +42,8 @@ def random_docs(
                 c.embedding = np.random.random(
                     [embed_dim + np.random.randint(0, jitter)]
                 )
-            c.tags['parent_id'] = doc_id
-            c.tags['id'] = chunk_doc_id
+            c.tags['parent_id'] = f'my parent is: {id}'
+            c.tags['id'] = f'myself id is: {doc_id}'
             d.chunks.append(c)
             next_chunk_doc_id += 1
 
diff --git a/tests/unit/test_pydantic.py b/tests/unit/test_pydantic.py
--- a/tests/unit/test_pydantic.py
+++ b/tests/unit/test_pydantic.py
@@ -2,6 +2,7 @@
 from typing import List, Optional
 
 import numpy as np
+import pytest
 from fastapi import FastAPI
 from pydantic import BaseModel
 from starlette.testclient import TestClient
@@ -116,3 +117,28 @@ def test_match_to_from_pydantic():
 def test_with_embedding_no_tensor():
     d = Document(embedding=np.random.rand(2, 2))
     PydanticDocument.parse_obj(d.to_pydantic_model().dict())
+
+
+@pytest.mark.parametrize(
+    'tag_value, tag_type',
+    [(3, float), (3.4, float), ('hello', str), (True, bool), (False, bool)],
+)
+@pytest.mark.parametrize('protocol', ['protobuf', 'jsonschema'])
+def test_tags_int_float_str_bool(tag_type, tag_value, protocol):
+    d = Document(tags={'hello': tag_value})
+    dd = d.to_dict(protocol=protocol)['tags']['hello']
+    assert dd == tag_value
+    assert isinstance(dd, tag_type)
+
+    # now nested tags in dict
+
+    d = Document(tags={'hello': {'world': tag_value}})
+    dd = d.to_dict(protocol=protocol)['tags']['hello']['world']
+    assert dd == tag_value
+    assert isinstance(dd, tag_type)
+
+    # now nested in list
+    d = Document(tags={'hello': [tag_value] * 10})
+    dd = d.to_dict(protocol=protocol)['tags']['hello'][-1]
+    assert dd == tag_value
+    assert isinstance(dd, tag_type)