internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: saleor/saleor

Issue:
Bug: Table django_prices_openexchangerates_conversionrate is not dropped in migrations
### What are you trying to achieve?

Clean up database schema of Saleor environments upgrated to v3.15 from older versions.

https://github.com/saleor/saleor/pull/13175 drops `django_prices_openexchangerates` from installed apps.
Django has no build-in mechanism for dropping unexpected tables.

Please introduce addition migration that cleans DB schema.

Unexpected table in schema breaks database replicaion tools

### Steps to reproduce the problem

1. Setup Saleor v3.14 envrionment
2. Update to v3.15 and run migrations
3. List all DB tables, `django_prices_openexchangerates_conversionrate` is still present



Discussion:
More tables that should be dropped:
- `django_prices_vatlayer_ratetypes`
- `django_prices_vatlayer_vat`

These are left after removing Vatlayer package: https://github.com/saleor/saleor/pull/13179

Resolving patch:
diff --git a/saleor/core/migrations/0008_drop_openexchangerates_table.py b/saleor/core/migrations/0008_drop_openexchangerates_table.py
new file mode 100644
--- /dev/null
+++ b/saleor/core/migrations/0008_drop_openexchangerates_table.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.2.21 on 2023-09-05 11:01
+
+from django.db import migrations
+
+# Drop tables that were used by packages that are no longer used:
+# - `django-prices-openexchangerates` - removed in https://github.com/saleor/saleor/pull/13175/
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("core", "0007_delete_celerytask"),
+    ]
+
+    operations = [
+        migrations.RunSQL(
+            sql="DROP TABLE IF EXISTS django_prices_openexchangerates_conversionrate;",
+            reverse_sql=migrations.RunSQL.noop,
+        ),
+    ]
diff --git a/saleor/core/migrations/0009_drop_vatlayer_tables.py b/saleor/core/migrations/0009_drop_vatlayer_tables.py
new file mode 100644
--- /dev/null
+++ b/saleor/core/migrations/0009_drop_vatlayer_tables.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.2.21 on 2023-09-05 13:09
+
+from django.db import migrations
+
+# Drop tables that were used by packages that are no longer used:
+# - `django-prices-vatlayer` - removed in https://github.com/saleor/saleor/pull/13179/
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("core", "0008_drop_openexchangerates_table"),
+        ("tax", "0007_auto_20230217_0837"),
+    ]
+
+    operations = [
+        migrations.RunSQL(
+            sql="DROP TABLE IF EXISTS django_prices_vatlayer_ratetypes",
+            reverse_sql=migrations.RunSQL.noop,
+        ),
+        migrations.RunSQL(
+            sql="DROP TABLE IF EXISTS django_prices_vatlayer_vat;",
+            reverse_sql=migrations.RunSQL.noop,
+        ),
+    ]


Test patch:
Repository: saleor/saleor

Issue:
Unsafe redirect to URL with protocol 'https'
Possibly affected class of: HttpResponseRedirect or a function that uses it under the hood (e.g. render)

Sentry errors: 
https://saleor.sentry.io/issues/3853339977/?project=6417854&referrer=project-issue-stream&statsPeriod=7d

Example trace: https://app.datadoghq.com/apm/traces?query=env%3A%22production%22%20service%3A%22core%22%20resource_name%3A%22tenants.middleware.SaleorTenantMiddleware.__call__%22%20host%3A%22i-07a9430cb955ae8c0%22%20%40version%3A%223.9.29-60f9135%22&env=production&graphType=flamegraph&historicalData=true&shouldShowLegend=true&trace=a50cb3ed5652c718&traceID=17467183125630341282&start=1678286090486&end=1678286150486&paused=true


Discussion:
I found the culprit, the Adyen plugin is accidentally modifying the `HttpResponseRedirect` class:

https://github.com/saleor/saleor/blob/9d4df5e2ae6926ff95fd347e5fb8309263d8f069/saleor/payment/gateways/adyen/webhooks.py#L1074-L1075

Resolving patch:
diff --git a/saleor/payment/gateways/adyen/webhooks.py b/saleor/payment/gateways/adyen/webhooks.py
--- a/saleor/payment/gateways/adyen/webhooks.py
+++ b/saleor/payment/gateways/adyen/webhooks.py
@@ -1002,6 +1002,13 @@ def handle_webhook(request: WSGIRequest, gateway_config: "GatewayConfig"):
     return HttpResponse("[accepted]")
 
 
+class HttpResponseRedirectWithTrustedProtocol(HttpResponseRedirect):
+    def __init__(self, redirect_to: str, *args, **kwargs) -> None:
+        parsed = urlparse(redirect_to)
+        self.allowed_schemes = [parsed.scheme]
+        super().__init__(redirect_to, *args, **kwargs)
+
+
 @transaction_with_commit_on_errors()
 def handle_additional_actions(
     request: WSGIRequest, payment_details: Callable, channel_slug: str
@@ -1070,10 +1077,7 @@ def handle_additional_actions(
         return HttpResponseBadRequest(str(e))
     handle_api_response(payment, checkout, result, channel_slug)
     redirect_url = prepare_redirect_url(payment_id, checkout_pk, result, return_url)
-    parsed = urlparse(return_url)
-    redirect_class = HttpResponseRedirect
-    redirect_class.allowed_schemes = [parsed.scheme]
-    return redirect_class(redirect_url)
+    return HttpResponseRedirectWithTrustedProtocol(redirect_url)
 
 
 def prepare_api_request_data(request: WSGIRequest, data: dict):


Test patch:
Repository: mirumee/ariadne

Issue:
Drop Python 3.5
Due to lack of support for [variable type annotations](https://www.python.org/dev/peps/pep-0526/) I suggest to drop support for Python 3.5. This is already a problem in #30 in which either code or mypy is failing and only solution is to remove hints.

We might consider testing ariadne on 3.7 for future-proofing our project.


Discussion:
To test Python 3.7 on Travis CI, a little workaround is needed: https://github.com/travis-ci/travis-ci/issues/9815.
Based on feedback we are getting, the strongest argument for dropping 3.5 would be moving to [GraphQL-Core-Next](https://github.com/graphql-python/graphql-core-next), thus letting folk experiment with async resolvers.

Originally we've started out with py3.5 because we were eyeing possible use in the Saleor and they have 3.5 on supported python versions list, but I've discussed this with @maarcingebala recently and Saleor will stick to Graphene for some time now, so we can cross this off the concerns list.

The next core was still work in progress back when we were making a push for query execution milestone, but now that its out, we could hop to it. Only gotcha here is that we'll have to create a shallow fork that namespaces it to `graphql_next` to support projects that will want to try it out side by side to GraphQL.

Resolving patch:
diff --git a/ariadne/executable_schema.py b/ariadne/executable_schema.py
--- a/ariadne/executable_schema.py
+++ b/ariadne/executable_schema.py
@@ -18,7 +18,7 @@ def flatten(rm):
 
 
 def merge_resolvers(resolver_list: Iterator[tuple]) -> dict:
-    output = defaultdict(dict)  # type: dict
+    output: dict = defaultdict(dict)
     for key, resolver_name, resolver in resolver_list:
         output[key][resolver_name] = resolver
     return output
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,6 @@
     "License :: OSI Approved :: BSD License",
     "Operating System :: OS Independent",
     "Programming Language :: Python",
-    "Programming Language :: Python :: 3.5",
     "Programming Language :: Python :: 3.6",
     "Programming Language :: Python :: 3.7",
     "Topic :: Software Development :: Libraries :: Python Modules",


Test patch:
Repository: mirumee/ariadne

Issue:
AttributeError: type object 'Callable' has no attribute '_abc_registry'
This problem occurs on Python 3.7 in AWS Lambda (but not locally).

```
[ERROR] AttributeError: type object 'Callable' has no attribute '_abc_registry'
Traceback (most recent call last):
  File "/var/lang/lib/python3.7/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/var/lang/lib/python3.7/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/itpieces/api/graphql_/__init__.py", line 3, in <module>
    from ariadne import graphql_sync
  File "/var/task/ariadne/__init__.py", line 1, in <module>
    from .enums import EnumType
  File "/var/task/ariadne/enums.py", line 3, in <module>
    from typing import Any, Dict, Union
  File "/var/task/typing.py", line 1356, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/var/task/typing.py", line 1004, in __new__
    self._abc_registry = extra._abc_registry
```

I noticed that Ariadne has `typing` as a dependency. Perhaps this is clashing with `typing` from the Python 3.7 standard library?

#### Suggested solution
Only install `typing` when `python_version<"3.5"` (Reference: [Python typing module](https://github.com/python/typing/issues/573))


Discussion:
Interesting that it works for us with the backport installed. I'm not sure we actually need the `typing` dependency at all. We already depend on `typing_extensions` which should provide all the necessary types across Python versions 3.5-3.7. @rafalp?
I was able to work around the issue by excluding `typing` from the deployment package.

**serverless.yml**:
```
custom:
  pythonRequirements:
    noDeploy:
    - typing
```
We only support 3.6+, so I'll cook up a PR today to drop explicit `typing` dependency.

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -28,9 +28,9 @@
 author = "Mirumee Software"
 
 # The short X.Y version
-version = "3"
+version = "4"
 # The full version, including alpha/beta/rc tags
-release = "0.3"
+release = "0.4"
 
 
 # -- General configuration ---------------------------------------------------
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -25,13 +25,12 @@
     long_description=README,
     long_description_content_type="text/markdown",
     license="BSD",
-    version="0.3.0",
+    version="0.4.0",
     url="https://github.com/mirumee/ariadne",
     packages=["ariadne"],
     install_requires=[
         "graphql-core-next>=1.0.1",
         "starlette>=0.11.4",
-        "typing>=3.6.0",
         "typing_extensions>=3.6.0",
     ],
     classifiers=CLASSIFIERS,


Test patch:
Repository: mirumee/ariadne

Issue:
Move documentation to separate repo and host it on gh-pages
Sphinx has served us well, but we fell its too limiting for what we have planned for Ariadne.

We've decided to migrate the site to the [Docusaurus](https://docusaurus.io) and keep it on separate repo.


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -42,7 +42,7 @@
 # Add any Sphinx extension module names here, as strings. They can be
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
-extensions = ["sphinxcontrib.asyncio"]
+extensions = []
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ["_templates"]


Test patch:
Repository: mirumee/ariadne

Issue:
Update setup.py to include html and py.typed files in published package
Ariadne now includes `graphql_playground.html` django template and `py.typed` file for enabling typing. We should make sure those two get published together with rest of the project.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@
     version="0.4.0",
     url="https://github.com/mirumee/ariadne",
     packages=["ariadne"],
-    package_data={"ariadne": ["py.typed"]},
+    include_package_data=True,
     install_requires=[
         "graphql-core-next>=1.0.4",
         "starlette<0.13",


Test patch:
Repository: mirumee/ariadne

Issue:
Async context_value callable is not supported
Our ASGI GraphQL app supports callable `context_value`, but it doesnt support `async` callable, so it's impossible to do any async work in it like get user form database. 😂

Example:

```python
async def resolve_context(request: Request) -> Dict:
    return {"user": await get_user_for_request(request)}


graphql_app = GraphQL(schema, context_value=resolve_context)
```


Discussion:

Resolving patch:
diff --git a/ariadne/asgi.py b/ariadne/asgi.py
--- a/ariadne/asgi.py
+++ b/ariadne/asgi.py
@@ -1,5 +1,6 @@
 import asyncio
 import json
+from inspect import isawaitable
 from typing import (
     Any,
     AsyncGenerator,
@@ -79,7 +80,11 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send):
 
     async def get_context_for_request(self, request: Any) -> Any:
         if callable(self.context_value):
-            return self.context_value(request)
+            context = self.context_value(request)
+            if isawaitable(context):
+                context = await context
+            return context
+
         return self.context_value or {"request": request}
 
     async def get_extensions_for_request(self, request: Any) -> ExtensionList:


Test patch:
diff --git a/tests/asgi/test_configuration.py b/tests/asgi/test_configuration.py
--- a/tests/asgi/test_configuration.py
+++ b/tests/asgi/test_configuration.py
@@ -36,6 +36,18 @@ def test_custom_context_value_function_result_is_passed_to_resolvers(schema):
     assert response.json() == {"data": {"testContext": "TEST-CONTEXT"}}
 
 
+def test_async_context_value_function_result_is_awaited_before_passing_to_resolvers(
+    schema
+):
+    async def get_context_value(*_):
+        return {"test": "TEST-ASYNC-CONTEXT"}
+
+    app = GraphQL(schema, context_value=get_context_value)
+    client = TestClient(app)
+    response = client.post("/", json={"query": "{ testContext }"})
+    assert response.json() == {"data": {"testContext": "TEST-ASYNC-CONTEXT"}}
+
+
 def test_custom_root_value_is_passed_to_query_resolvers(schema):
     app = GraphQL(schema, root_value={"test": "TEST-ROOT"})
     client = TestClient(app)
Repository: mirumee/ariadne

Issue:
Update GraphQL Core Next & Starlette
Issue for me to remember to update our core dependencies to latest versions before release.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,7 @@
     packages=["ariadne"],
     include_package_data=True,
     install_requires=[
-        "graphql-core-next>=1.0.4",
+        "graphql-core-next<3.0.0",
         "python-multipart>=0.0.5",
         "starlette<0.13",
         "typing_extensions>=3.6.0",


Test patch:
diff --git a/tests/test_schema_file_load.py b/tests/test_schema_file_load.py
--- a/tests/test_schema_file_load.py
+++ b/tests/test_schema_file_load.py
@@ -45,7 +45,7 @@ def incorrect_schema_file(tmpdir_factory):
 def test_loading_schema_fails_on_bad_syntax(incorrect_schema_file):
     with pytest.raises(exceptions.GraphQLFileSyntaxError) as e:
         load_schema_from_path(str(incorrect_schema_file))
-    assert str(incorrect_schema_file) in str(e)
+    assert str(incorrect_schema_file) in str(e.value)
 
 
 SECOND_SCHEMA = """
diff --git a/tests/tracing/snapshots/snap_test_apollotracing.py b/tests/tracing/snapshots/snap_test_apollotracing.py
--- a/tests/tracing/snapshots/snap_test_apollotracing.py
+++ b/tests/tracing/snapshots/snap_test_apollotracing.py
@@ -36,43 +36,5 @@
 }
 
 snapshots['test_apollotracing_extension_handles_exceptions_in_resolvers 1'] = {
-    'data': {
-        'testError': None
-    },
-    'errors': [
-        {
-            'locations': [
-                (
-                    1,
-                    3
-                )
-            ],
-            'message': 'Test exception',
-            'path': [
-                'testError'
-            ]
-        }
-    ],
-    'extensions': {
-        'tracing': {
-            'duration': 0,
-            'endTime': '2012-01-14T03:21:34.000000Z',
-            'execution': {
-                'resolvers': [
-                    {
-                        'duration': 0,
-                        'fieldName': 'testError',
-                        'parentType': 'Query',
-                        'path': [
-                            'testError'
-                        ],
-                        'returnType': 'Boolean',
-                        'startOffset': 0
-                    }
-                ]
-            },
-            'startTime': '2012-01-14T03:21:34.000000Z',
-            'version': 1
-        }
-    }
+    'testError': None
 }
diff --git a/tests/tracing/test_apollotracing.py b/tests/tracing/test_apollotracing.py
--- a/tests/tracing/test_apollotracing.py
+++ b/tests/tracing/test_apollotracing.py
@@ -40,7 +40,7 @@ async def test_apollotracing_extension_handles_exceptions_in_resolvers(
     _, result = await graphql(
         schema, {"query": "{ testError }"}, extensions=[ApolloTracingExtension]
     )
-    snapshot.assert_match(result)
+    snapshot.assert_match(result["data"])
 
 
 @pytest.mark.asyncio
Repository: mirumee/ariadne

Issue:
Upgrade to GraphQL-core v3
I'm getting the following deprecation warning. Is this something that is already on your radar / that you are planning to resolve for the next release?

>**DeprecationWarning**: GraphQL-core-next has been discontinued. It is now released as GraphQL-core v3 and newer.


Discussion:
Thanks for raising this up.

We are aware that "GraphQL-core-next" v3 will be released as "GraphQL-core" v3, but there's currently no stable "GraphQL-core v3" release that we could update Ariadne to, with most recent release being [Alpha 2](https://pypi.org/project/graphql-core/#history).

On the flip-side of things, there are no known show-stopper issues in the version of GraphQL Core Next that we are using, sans this warning ;)
Yep, I saw. But thanks for clarifying regardless. :)

Just wanted to see whether it was on your radar and tracked somehow. It sounds like you got it covered :+1:
Core 3 is now out, so we can release new Ariadne version with GraphQL-core-3!

Marking this as help wanted cos I'm not sure when I'll find time to sit down and do deps bump for Ariadne 0.9 release. If somebody cooks up the PR that does this, they are welcome!

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@
     packages=["ariadne"],
     include_package_data=True,
     install_requires=[
-        "graphql-core-next<3.0.0",
+        "graphql-core>=3.0.0",
         "starlette<0.14",
         "typing_extensions>=3.6.0",
     ],


Test patch:
diff --git a/tests/asgi/snapshots/snap_test_query_execution.py b/tests/asgi/snapshots/snap_test_query_execution.py
--- a/tests/asgi/snapshots/snap_test_query_execution.py
+++ b/tests/asgi/snapshots/snap_test_query_execution.py
@@ -30,10 +30,10 @@
     'errors': [
         {
             'locations': [
-                [
-                    2,
-                    18
-                ]
+                {
+                    'column': 18,
+                    'line': 2
+                }
             ],
             'message': "Variable '$name' of required type 'String!' was not provided.",
             'path': None
@@ -94,10 +94,10 @@
 
 snapshots['test_attempt_execute_subscription_with_invalid_query_returns_error_json 1'] = {
     'locations': [
-        [
-            1,
-            16
-        ]
+        {
+            'column': 16,
+            'line': 1
+        }
     ],
     'message': "Cannot query field 'error' on type 'Subscription'.",
     'path': None
diff --git a/tests/wsgi/snapshots/snap_test_query_execution.py b/tests/wsgi/snapshots/snap_test_query_execution.py
--- a/tests/wsgi/snapshots/snap_test_query_execution.py
+++ b/tests/wsgi/snapshots/snap_test_query_execution.py
@@ -30,10 +30,10 @@
     'errors': [
         {
             'locations': [
-                [
-                    2,
-                    18
-                ]
+                {
+                    'column': 18,
+                    'line': 2
+                }
             ],
             'message': "Variable '$name' of required type 'String!' was not provided.",
             'path': None
Repository: mirumee/ariadne

Issue:
Exception in default_literal_parser() when ValueNode has no "value" member
The [default_literal_parser() function](https://github.com/mirumee/ariadne/blob/master/ariadne/scalars.py#L90) in ariadne.scalars expects nodes to have a "value" member.  However, this is not the case with, for example, `ObjectValueNode` or `ListValueNode`.  This causes an exception when trying to pass such nodes.

My suggestion is to use `graphql.utilities.value_from_ast_untyped` instead:
```
return value_parser(value_from_ast_untyped(ast))
``` 

I'm happy to do a PR if you guys like this change.


Discussion:
Yup, this sounds like a good improvement!

Resolving patch:
diff --git a/ariadne/scalars.py b/ariadne/scalars.py
--- a/ariadne/scalars.py
+++ b/ariadne/scalars.py
@@ -14,6 +14,7 @@
     GraphQLScalarValueParser,
     GraphQLSchema,
 )
+from graphql.utilities import value_from_ast_untyped
 
 from .types import SchemaBindable
 
@@ -87,6 +88,6 @@ def create_default_literal_parser(
     value_parser: GraphQLScalarValueParser,
 ) -> GraphQLScalarLiteralParser:
     def default_literal_parser(ast):
-        return value_parser(ast.value)
+        return value_parser(value_from_ast_untyped(ast))
 
     return default_literal_parser


Test patch:
diff --git a/tests/test_custom_scalars.py b/tests/test_custom_scalars.py
--- a/tests/test_custom_scalars.py
+++ b/tests/test_custom_scalars.py
@@ -250,13 +250,13 @@ def test_literal_string_is_deserialized_by_default_parser():
 def test_literal_int_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: 123) }")
     assert result.errors is None
-    assert result.data == {"testInputValueType": "str"}
+    assert result.data == {"testInputValueType": "int"}
 
 
 def test_literal_float_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: 1.5) }")
     assert result.errors is None
-    assert result.data == {"testInputValueType": "str"}
+    assert result.data == {"testInputValueType": "float"}
 
 
 def test_literal_bool_true_is_deserialized_by_default_parser():
@@ -269,3 +269,15 @@ def test_literal_bool_false_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: false) }")
     assert result.errors is None
     assert result.data == {"testInputValueType": "bool"}
+
+
+def test_literal_object_is_deserialized_by_default_parser():
+    result = graphql_sync(schema, "{ testInputValueType(value: {}) }")
+    assert result.errors is None
+    assert result.data == {"testInputValueType": "dict"}
+
+
+def test_literal_list_is_deserialized_by_default_parser():
+    result = graphql_sync(schema, "{ testInputValueType(value: []) }")
+    assert result.errors is None
+    assert result.data == {"testInputValueType": "list"}
Repository: mirumee/ariadne

Issue:
Release Ariadne 0.13
# TODO

- [x] Update dependencies
- [x] Fix linters errors on repo
- [x] #483 
- [x] Update changelog
- [x] Write [release notes](https://github.com/mirumee/ariadne-website/pull/75)
- [x] Reach to our amazing art team for tweet graphics


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -11,6 +11,7 @@
     "Programming Language :: Python :: 3.6",
     "Programming Language :: Python :: 3.7",
     "Programming Language :: Python :: 3.8",
+    "Programming Language :: Python :: 3.9",
     "Topic :: Software Development :: Libraries :: Python Modules",
 ]
 
@@ -26,7 +27,7 @@
     long_description=README,
     long_description_content_type="text/markdown",
     license="BSD",
-    version="0.12.0",
+    version="0.13.0",
     url="https://github.com/mirumee/ariadne",
     packages=["ariadne"],
     include_package_data=True,


Test patch: