Repository: mirumee/ariadne

Issue:
Is Python `multipart` module used anywhere?
I can't find it being imported anywhere in the code. I'm trying to get my Ariadne environment slimmed down as much as possible, so it would be useful to know if it is safe to remove that module. Thanks!


Discussion:
Its dependency for file uploads in ASGI server.
@rafalp Are there any plans to move `multipart` to extras_require? Dropping unused dependencies looks reasonable when we don't use file uploads feature of `ariadne` .
I guess we can make this optional for folk who need to keep their deps installation size cut to size.

Will need to add heads-up to our docs too, and likely update how we install things in tests.

Resolving patch:
diff --git a/ariadne/scalars.py b/ariadne/scalars.py
--- a/ariadne/scalars.py
+++ b/ariadne/scalars.py
@@ -84,7 +84,7 @@ def validate_graphql_type(self, graphql_type: Optional[GraphQLNamedType]) -> Non
 
 
 def create_default_literal_parser(
-    value_parser: GraphQLScalarValueParser
+    value_parser: GraphQLScalarValueParser,
 ) -> GraphQLScalarLiteralParser:
     def default_literal_parser(ast):
         return value_parser(ast.value)
diff --git a/ariadne/schema_visitor.py b/ariadne/schema_visitor.py
--- a/ariadne/schema_visitor.py
+++ b/ariadne/schema_visitor.py
@@ -200,7 +200,7 @@ def call_method(
         return type_
 
     def visit(  # pylint: disable=too-many-return-statements
-        type_: VisitableSchemaType
+        type_: VisitableSchemaType,
     ) -> Union[VisitableSchemaType, Literal[False]]:
         """
         Recursive helper function that calls any appropriate visitor methods for
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,10 +31,10 @@
     include_package_data=True,
     install_requires=[
         "graphql-core-next<3.0.0",
-        "python-multipart>=0.0.5",
-        "starlette<0.13",
+        "starlette<0.14",
         "typing_extensions>=3.6.0",
     ],
+    extras_require={"asgi-file-uploads": ["python-multipart>=0.0.5"]},
     classifiers=CLASSIFIERS,
     platforms=["any"],
     zip_safe=False,


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
@@ -38,7 +38,7 @@ def test_custom_context_value_function_result_is_passed_to_resolvers(schema):
 
 
 def test_async_context_value_function_result_is_awaited_before_passing_to_resolvers(
-    schema
+    schema,
 ):
     async def get_context_value(*_):
         return {"test": "TEST-ASYNC-CONTEXT"}
diff --git a/tests/django/test_configuration.py b/tests/django/test_configuration.py
--- a/tests/django/test_configuration.py
+++ b/tests/django/test_configuration.py
@@ -17,7 +17,7 @@ def execute_query(request_factory, schema, query, **kwargs):
 
 
 def test_value_error_is_raised_when_view_was_initialized_without_schema(
-    request_factory
+    request_factory,
 ):
     with pytest.raises(ValueError):
         execute_query(request_factory, None, {"query": "{ testContext }"})
diff --git a/tests/test_enums.py b/tests/test_enums.py
--- a/tests/test_enums.py
+++ b/tests/test_enums.py
@@ -94,7 +94,7 @@ def test_attempt_bind_custom_enum_to_wrong_schema_type_raises_error(schema_with_
 
 
 def test_attempt_bind_custom_enum_to_schema_enum_missing_value_raises_error(
-    schema_with_enum
+    schema_with_enum,
 ):
     graphql_enum = EnumType("Episode", {"JARJAR": 1999})
     with pytest.raises(ValueError):
diff --git a/tests/test_unions.py b/tests/test_unions.py
--- a/tests/test_unions.py
+++ b/tests/test_unions.py
@@ -127,7 +127,7 @@ def test_result_is_username_if_union_resolves_type_to_user(query_with_user_item)
 
 
 def test_result_is_thread_title_if_union_resolves_type_to_thread(
-    query_with_thread_item
+    query_with_thread_item,
 ):
     union = UnionType("FeedItem", type_resolver=resolve_result_type)
     schema = make_executable_schema(type_defs, [query_with_thread_item, union])