diff --git a/poetry.lock b/poetry.lock index 011101ff..c1665529 100644 --- a/poetry.lock +++ b/poetry.lock @@ -348,17 +348,18 @@ doc = ["Sphinx", "sphinx-rtd-theme", "sphinxcontrib-spelling"] [[package]] name = "faker" -version = "29.0.0" +version = "30.3.0" description = "Faker is a Python package that generates fake data for you." optional = false python-versions = ">=3.8" files = [ - {file = "Faker-29.0.0-py3-none-any.whl", hash = "sha256:32d0ee7d42925ff06e4a7d906ee7efbf34f5052a41a2a1eb8bb174a422a5498f"}, - {file = "faker-29.0.0.tar.gz", hash = "sha256:34e89aec594cad9773431ca479ee95c7ce03dd9f22fda2524e2373b880a2fa77"}, + {file = "Faker-30.3.0-py3-none-any.whl", hash = "sha256:e8a15fd1b0f72992b008f5ea94c70d3baa0cb51b0d5a0e899c17b1d1b23d2771"}, + {file = "faker-30.3.0.tar.gz", hash = "sha256:8760fbb34564fbb2f394345eef24aec5b8f6506b6cfcefe8195ed66dd1032bdb"}, ] [package.dependencies] python-dateutil = ">=2.4" +typing-extensions = "*" [[package]] name = "graphql-core" @@ -747,29 +748,29 @@ six = ">=1.5" [[package]] name = "ruff" -version = "0.6.7" +version = "0.6.9" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.6.7-py3-none-linux_armv6l.whl", hash = "sha256:08277b217534bfdcc2e1377f7f933e1c7957453e8a79764d004e44c40db923f2"}, - {file = "ruff-0.6.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:c6707a32e03b791f4448dc0dce24b636cbcdee4dd5607adc24e5ee73fd86c00a"}, - {file = "ruff-0.6.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:533d66b7774ef224e7cf91506a7dafcc9e8ec7c059263ec46629e54e7b1f90ab"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:17a86aac6f915932d259f7bec79173e356165518859f94649d8c50b81ff087e9"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b3f8822defd260ae2460ea3832b24d37d203c3577f48b055590a426a722d50ef"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9ba4efe5c6dbbb58be58dd83feedb83b5e95c00091bf09987b4baf510fee5c99"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:525201b77f94d2b54868f0cbe5edc018e64c22563da6c5c2e5c107a4e85c1c0d"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8854450839f339e1049fdbe15d875384242b8e85d5c6947bb2faad33c651020b"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2f0b62056246234d59cbf2ea66e84812dc9ec4540518e37553513392c171cb18"}, - {file = "ruff-0.6.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b1462fa56c832dc0cea5b4041cfc9c97813505d11cce74ebc6d1aae068de36b"}, - {file = "ruff-0.6.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:02b083770e4cdb1495ed313f5694c62808e71764ec6ee5db84eedd82fd32d8f5"}, - {file = "ruff-0.6.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c05fd37013de36dfa883a3854fae57b3113aaa8abf5dea79202675991d48624"}, - {file = "ruff-0.6.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f49c9caa28d9bbfac4a637ae10327b3db00f47d038f3fbb2195c4d682e925b14"}, - {file = "ruff-0.6.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a0e1655868164e114ba43a908fd2d64a271a23660195017c17691fb6355d59bb"}, - {file = "ruff-0.6.7-py3-none-win32.whl", hash = "sha256:a939ca435b49f6966a7dd64b765c9df16f1faed0ca3b6f16acdf7731969deb35"}, - {file = "ruff-0.6.7-py3-none-win_amd64.whl", hash = "sha256:590445eec5653f36248584579c06252ad2e110a5d1f32db5420de35fb0e1c977"}, - {file = "ruff-0.6.7-py3-none-win_arm64.whl", hash = "sha256:b28f0d5e2f771c1fe3c7a45d3f53916fc74a480698c4b5731f0bea61e52137c8"}, - {file = "ruff-0.6.7.tar.gz", hash = "sha256:44e52129d82266fa59b587e2cd74def5637b730a69c4542525dfdecfaae38bd5"}, + {file = "ruff-0.6.9-py3-none-linux_armv6l.whl", hash = "sha256:064df58d84ccc0ac0fcd63bc3090b251d90e2a372558c0f057c3f75ed73e1ccd"}, + {file = "ruff-0.6.9-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:140d4b5c9f5fc7a7b074908a78ab8d384dd7f6510402267bc76c37195c02a7ec"}, + {file = "ruff-0.6.9-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53fd8ca5e82bdee8da7f506d7b03a261f24cd43d090ea9db9a1dc59d9313914c"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645d7d8761f915e48a00d4ecc3686969761df69fb561dd914a773c1a8266e14e"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eae02b700763e3847595b9d2891488989cac00214da7f845f4bcf2989007d577"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7d5ccc9e58112441de8ad4b29dcb7a86dc25c5f770e3c06a9d57e0e5eba48829"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:417b81aa1c9b60b2f8edc463c58363075412866ae4e2b9ab0f690dc1e87ac1b5"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c866b631f5fbce896a74a6e4383407ba7507b815ccc52bcedabb6810fdb3ef7"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7b118afbb3202f5911486ad52da86d1d52305b59e7ef2031cea3425142b97d6f"}, + {file = "ruff-0.6.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a67267654edc23c97335586774790cde402fb6bbdb3c2314f1fc087dee320bfa"}, + {file = "ruff-0.6.9-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3ef0cc774b00fec123f635ce5c547dac263f6ee9fb9cc83437c5904183b55ceb"}, + {file = "ruff-0.6.9-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:12edd2af0c60fa61ff31cefb90aef4288ac4d372b4962c2864aeea3a1a2460c0"}, + {file = "ruff-0.6.9-py3-none-musllinux_1_2_i686.whl", hash = "sha256:55bb01caeaf3a60b2b2bba07308a02fca6ab56233302406ed5245180a05c5625"}, + {file = "ruff-0.6.9-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:925d26471fa24b0ce5a6cdfab1bb526fb4159952385f386bdcc643813d472039"}, + {file = "ruff-0.6.9-py3-none-win32.whl", hash = "sha256:eb61ec9bdb2506cffd492e05ac40e5bc6284873aceb605503d8494180d6fc84d"}, + {file = "ruff-0.6.9-py3-none-win_amd64.whl", hash = "sha256:785d31851c1ae91f45b3d8fe23b8ae4b5170089021fbb42402d811135f0b7117"}, + {file = "ruff-0.6.9-py3-none-win_arm64.whl", hash = "sha256:a9641e31476d601f83cd602608739a0840e348bda93fec9f1ee816f8b6798b93"}, + {file = "ruff-0.6.9.tar.gz", hash = "sha256:b076ef717a8e5bc819514ee1d602bbdca5b4420ae13a9cf61a0c0a4f53a2baa2"}, ] [[package]] @@ -820,13 +821,13 @@ doc = ["sphinx"] [[package]] name = "strawberry-graphql" -version = "0.242.0" +version = "0.246.1" description = "A library for creating GraphQL APIs" optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "strawberry_graphql-0.242.0-py3-none-any.whl", hash = "sha256:a0b148454336a81471b8ac2708be0c948b9b4e29915f68264d3b909774c7f04a"}, - {file = "strawberry_graphql-0.242.0.tar.gz", hash = "sha256:2042f24a796a95b7ce938edb8c0e1c887a480176bba1ca20250270589a1fbbb0"}, + {file = "strawberry_graphql-0.246.1-py3-none-any.whl", hash = "sha256:4d2e7dd7b4f0776a31aefd60bb30430e28c9431bd5fe851637c328416cd1a413"}, + {file = "strawberry_graphql-0.246.1.tar.gz", hash = "sha256:f6eecca7eb823e55da9c20a9d4408c4fa029aac7ada83a0414e9fec1c11644a9"}, ] [package.dependencies] @@ -855,13 +856,13 @@ sanic = ["sanic (>=20.12.2)"] [[package]] name = "tomli" -version = "2.0.1" +version = "2.0.2" description = "A lil' TOML parser" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, + {file = "tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38"}, + {file = "tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed"}, ] [[package]] diff --git a/strawberry_django/fields/types.py b/strawberry_django/fields/types.py index 1fcd395e..fae48869 100644 --- a/strawberry_django/fields/types.py +++ b/strawberry_django/fields/types.py @@ -418,7 +418,7 @@ def _resolve_array_field_type(model_field: Field): return List[_resolve_array_field_type(model_field.base_field)] base_field = field_type_map.get(type(model_field), NotImplemented) - if base_field is NotImplemented: + if base_field is NotImplemented: # type: ignore raise NotImplementedError( f"GraphQL type for model field '{model_field}' has not been implemented", ) diff --git a/strawberry_django/mutations/fields.py b/strawberry_django/mutations/fields.py index 5f039db0..f9ef37c6 100644 --- a/strawberry_django/mutations/fields.py +++ b/strawberry_django/mutations/fields.py @@ -131,7 +131,7 @@ def resolve_type( name = capitalize_first(to_camel_case(self.python_name)) resolved = Annotated[ - Union[types_], # type: ignore + Union[types_], strawberry.union(f"{name}Payload"), ] self.type_annotation = StrawberryAnnotation( diff --git a/strawberry_django/test/client.py b/strawberry_django/test/client.py index 76c2c268..cfe889c0 100644 --- a/strawberry_django/test/client.py +++ b/strawberry_django/test/client.py @@ -1,4 +1,5 @@ import contextlib +import warnings from typing import Any, Awaitable, Dict, Optional, cast from asgiref.sync import sync_to_async @@ -6,6 +7,7 @@ from django.test.client import AsyncClient, Client # type: ignore from strawberry.test import BaseGraphQLTestClient from strawberry.test.client import Response +from typing_extensions import override class TestClient(BaseGraphQLTestClient): @@ -49,13 +51,15 @@ def __init__(self, path: str, client: Optional[AsyncClient] = None): def client(self) -> AsyncClient: return self._client + @override async def query( self, query: str, variables: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, object]] = None, - asserts_errors: Optional[bool] = True, + asserts_errors: Optional[bool] = None, files: Optional[Dict[str, object]] = None, + assert_no_errors: Optional[bool] = True, ) -> Response: body = self._build_body(query, variables, files) @@ -67,8 +71,19 @@ async def query( data=data.get("data"), extensions=data.get("extensions"), ) - if asserts_errors: - assert response.errors is None, response.errors + + if asserts_errors is not None: + warnings.warn( + "The `asserts_errors` argument has been renamed to `assert_no_errors`", + DeprecationWarning, + stacklevel=2, + ) + + assert_no_errors = ( + assert_no_errors if asserts_errors is None else asserts_errors + ) + if assert_no_errors: + assert response.errors is None return response diff --git a/tests/utils.py b/tests/utils.py index 80416bbb..9275e512 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,6 +3,7 @@ import contextvars import dataclasses import inspect +import warnings from typing import Any, Dict, Optional, Union import strawberry @@ -14,6 +15,7 @@ from django.test.utils import CaptureQueriesContext from strawberry.test.client import Response from strawberry.utils.inspect import in_async_context +from typing_extensions import override from strawberry_django.optimizer import DjangoOptimizerExtension from strawberry_django.test.client import TestClient @@ -147,13 +149,15 @@ def request( **kwargs, # type: ignore ) + @override def query( self, query: str, variables: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, object]] = None, - asserts_errors: Optional[bool] = True, + asserts_errors: Optional[bool] = None, files: Optional[Dict[str, object]] = None, + assert_no_errors: Optional[bool] = True, ) -> Response: body = self._build_body(query, variables, files) @@ -168,7 +172,18 @@ def query( data=data.get("data"), extensions=data.get("extensions"), ) - if asserts_errors: - assert response.errors is None, response.errors + + if asserts_errors is not None: + warnings.warn( + "The `asserts_errors` argument has been renamed to `assert_no_errors`", + DeprecationWarning, + stacklevel=2, + ) + + assert_no_errors = ( + assert_no_errors if asserts_errors is None else asserts_errors + ) + if assert_no_errors: + assert response.errors is None return response