From 24156baa8eaf732ec9893532c1864ce4e5466cc4 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Tue, 25 Jan 2022 15:13:51 -0800 Subject: [PATCH 01/18] Fix compatibility with starlette 0.18.0 --- strawberry/asgi/handlers/http_handler.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index 2b3c808fd4..11646d3d56 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -39,13 +39,7 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): request = Request(scope=scope, receive=receive) root_value = await self.get_root_value(request) - sub_response = Response( - content=None, - status_code=None, # type: ignore - headers=None, - media_type=None, - background=None, - ) + sub_response = Response() context = await self.get_context(request=request, response=sub_response) @@ -57,7 +51,8 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): context=context, ) - response.headers.raw.extend(sub_response.headers.raw) + # Only add headers from sub_response if they're not already present in response + response.headers.raw.extend((k, v) for k, v in sub_response.headers.raw if k not in {k for k, _ in response.headers.raw}) if sub_response.background: response.background = sub_response.background From b415ee1e56ecbc0d36965db7e448c290167878f2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jan 2022 23:15:19 +0000 Subject: [PATCH 02/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strawberry/asgi/handlers/http_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index 11646d3d56..afce35c244 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -52,7 +52,11 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): ) # Only add headers from sub_response if they're not already present in response - response.headers.raw.extend((k, v) for k, v in sub_response.headers.raw if k not in {k for k, _ in response.headers.raw}) + response.headers.raw.extend( + (k, v) + for k, v in sub_response.headers.raw + if k not in {k for k, _ in response.headers.raw} + ) if sub_response.background: response.background = sub_response.background From 84fdf9931086cee671c62aa930e79606d9e30751 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 26 Jan 2022 10:52:34 -0800 Subject: [PATCH 03/18] Add warnings for duplicate headers. --- strawberry/asgi/handlers/http_handler.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index afce35c244..7d7da2d506 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -1,4 +1,5 @@ import json +import warnings from typing import Any, Callable, Dict, Iterable, Optional from starlette import status @@ -52,11 +53,20 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): ) # Only add headers from sub_response if they're not already present in response - response.headers.raw.extend( - (k, v) - for k, v in sub_response.headers.raw - if k not in {k for k, _ in response.headers.raw} - ) + duplicate_headers = [] + response_headers_keys = {k for k, _ in response.headers.raw} + + for k, v in sub_response.headers.raw: + if k not in response_headers_keys: + response.headers.raw.append((k, v)) + elif k != b"content-length": + duplicate_headers.append(k) + + # Warning for any duplicate headers found + if duplicate_headers: + warnings.warn( + "Duplicate headers in sub response found. {0}".format(duplicate_headers) + ) if sub_response.background: response.background = sub_response.background From 0cda8f38bda4d9250c41e8a3feb2473aaab2312a Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 26 Jan 2022 11:10:48 -0800 Subject: [PATCH 04/18] Update starlette version requirements --- poetry.lock | 28 ++++++++++++++-------------- pyproject.toml | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/poetry.lock b/poetry.lock index 3ba4bc078c..fd356c1173 100644 --- a/poetry.lock +++ b/poetry.lock @@ -357,7 +357,7 @@ python-versions = "*" [[package]] name = "fastapi" -version = "0.70.1" +version = "0.76.0" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" category = "main" optional = false @@ -365,13 +365,13 @@ python-versions = ">=3.6.1" [package.dependencies] pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0" -starlette = "0.16.0" +starlette = "0.18.0" [package.extras] -all = ["requests (>=2.24.0,<3.0.0)", "jinja2 (>=2.11.2,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<3.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "ujson (>=4.0.1,<5.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.16.0)"] -dev = ["python-jose[cryptography] (>=3.3.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.4.0,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.16.0)"] -doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=7.1.9,<8.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "typer-cli (>=0.0.12,<0.0.13)", "pyyaml (>=5.3.1,<6.0.0)"] -test = ["pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "mypy (==0.910)", "flake8 (>=3.8.3,<4.0.0)", "black (==21.9b0)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.6.0)", "orjson (>=3.2.1,<4.0.0)", "ujson (>=4.0.1,<5.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "flask (>=1.1.2,<3.0.0)", "anyio[trio] (>=3.2.1,<4.0.0)", "types-ujson (==0.1.1)", "types-orjson (==3.6.0)", "types-dataclasses (==0.1.7)"] +all = ["requests (>=2.24.0,<3.0.0)", "jinja2 (>=2.11.2,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<3.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"] +dev = ["python-jose[cryptography] (>=3.3.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.4.0,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"] +doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "typer (>=0.4.1,<0.5.0)", "pyyaml (>=5.3.1,<7.0.0)"] +test = ["pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "mypy (==0.910)", "flake8 (>=3.8.3,<4.0.0)", "black (==22.3.0)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.6.0)", "orjson (>=3.2.1,<4.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "flask (>=1.1.2,<3.0.0)", "anyio[trio] (>=3.2.1,<4.0.0)", "types-ujson (==4.2.1)", "types-orjson (==3.6.2)", "types-dataclasses (==0.6.5)"] [[package]] name = "filelock" @@ -1244,7 +1244,7 @@ python-versions = ">=3.5" [[package]] name = "starlette" -version = "0.16.0" +version = "0.18.0" description = "The little ASGI library that shines." category = "main" optional = false @@ -1252,10 +1252,10 @@ python-versions = ">=3.6" [package.dependencies] anyio = ">=3.0.0,<4" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} +typing-extensions = {version = "*", markers = "python_version < \"3.10\""} [package.extras] -full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "graphene"] +full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"] [[package]] name = "testfixtures" @@ -1538,7 +1538,7 @@ sanic = ["sanic"] [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "af82d5643a95bb51c6ad9086fc3979dd9362bb0ca5b5160801616f79f25c6393" +content-hash = "0602fe5053113b31cddd218b3754d0218ebe8578f559a6fc4a3e70e1687061a3" [metadata.files] aiofiles = [ @@ -1788,8 +1788,8 @@ eradicate = [ {file = "eradicate-2.1.0.tar.gz", hash = "sha256:aac7384ab25b1bf21c4c012de9b4bf8398945a14c98c911545b2ea50ab558014"}, ] fastapi = [ - {file = "fastapi-0.70.1-py3-none-any.whl", hash = "sha256:5367226c7bcd7bfb2e17edaf225fd9a983095b1372281e9a3eb661336fb93748"}, - {file = "fastapi-0.70.1.tar.gz", hash = "sha256:21d03979b5336375c66fa5d1f3126c6beca650d5d2166fbb78345a30d33c8d06"}, + {file = "fastapi-0.76.0-py3-none-any.whl", hash = "sha256:1e05c868651e3935bd9b290c61a3661a54e37471d3a0700bc5e4380f9ed935ae"}, + {file = "fastapi-0.76.0.tar.gz", hash = "sha256:a5f99f6e827c7108a8efaf1d7f19d6cf2d735ad984f5e44d33ccec6ee88a7da1"}, ] filelock = [ {file = "filelock-3.7.0-py3-none-any.whl", hash = "sha256:c7b5fdb219b398a5b28c8e4c1893ef5f98ece6a38c6ab2c22e26ec161556fed6"}, @@ -2470,8 +2470,8 @@ sqlparse = [ {file = "sqlparse-0.4.2.tar.gz", hash = "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae"}, ] starlette = [ - {file = "starlette-0.16.0-py3-none-any.whl", hash = "sha256:38eb24bf705a2c317e15868e384c1b8a12ca396e5a3c3a003db7e667c43f939f"}, - {file = "starlette-0.16.0.tar.gz", hash = "sha256:e1904b5d0007aee24bdd3c43994be9b3b729f4f58e740200de1d623f8c3a8870"}, + {file = "starlette-0.18.0-py3-none-any.whl", hash = "sha256:377d64737a0e03560cb8eaa57604afee143cea5a4996933242798a7820e64f53"}, + {file = "starlette-0.18.0.tar.gz", hash = "sha256:b45c6e9a617ecb5caf7e6446bd8d767b0084d6217e8e1b08187ca5191e10f097"}, ] testfixtures = [ {file = "testfixtures-6.18.5-py2.py3-none-any.whl", hash = "sha256:7de200e24f50a4a5d6da7019fb1197aaf5abd475efb2ec2422fdcf2f2eb98c1d"}, diff --git a/pyproject.toml b/pyproject.toml index 6603bd7353..f79b34e1fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ build-backend = "poetry.masonry.api" [tool.poetry.dependencies] python = "^3.7" -starlette = {version = ">=0.13.6,<0.17.0", optional = true} +starlette = {version = ">=0.13.6,<0.19.0", optional = true} click = {version = ">=7.0,<9.0", optional = true} pygments = "^2.3" uvicorn = {version = ">=0.11.6,<0.18.0", optional = true} @@ -76,8 +76,8 @@ flake8-black = "^0.3" Django = ">=3.2" pydantic = {version = "<2", optional = false} email-validator = {version = "^1.1.3", optional = false} -starlette = ">=0.13.6,<0.17.0" -uvicorn = ">=0.11.6,<0.18.0" +uvicorn = ">=0.11.6" +starlette = ">=0.13.6" sanic = ">=20.12.2,<22.0.0" aiohttp = "^3.7.4.post0" pytest-aiohttp = "^1.0.3" From b2f8e684add445d0de9eab0ae6d234978aff3c70 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 26 Jan 2022 11:10:57 -0800 Subject: [PATCH 05/18] Fix issues with status code defaults --- strawberry/asgi/handlers/http_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index 7d7da2d506..fb0c5bd45b 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -41,6 +41,9 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): root_value = await self.get_root_value(request) sub_response = Response() + if sub_response.status_code == 200: + # Set default status code to None + sub_response.status_code = None # typing: ignore context = await self.get_context(request=request, response=sub_response) From 1d413927c8feb4d3884c71e7177db1535bc6aab5 Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 2 Feb 2022 11:29:48 -0800 Subject: [PATCH 06/18] Simplify sub_response logic for starlette --- strawberry/asgi/handlers/http_handler.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index fb0c5bd45b..b97266117b 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -41,9 +41,8 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): root_value = await self.get_root_value(request) sub_response = Response() - if sub_response.status_code == 200: - # Set default status code to None - sub_response.status_code = None # typing: ignore + sub_response.status_code = None # typing: ignore + del sub_response.headers["content-length"] context = await self.get_context(request=request, response=sub_response) @@ -55,22 +54,6 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): context=context, ) - # Only add headers from sub_response if they're not already present in response - duplicate_headers = [] - response_headers_keys = {k for k, _ in response.headers.raw} - - for k, v in sub_response.headers.raw: - if k not in response_headers_keys: - response.headers.raw.append((k, v)) - elif k != b"content-length": - duplicate_headers.append(k) - - # Warning for any duplicate headers found - if duplicate_headers: - warnings.warn( - "Duplicate headers in sub response found. {0}".format(duplicate_headers) - ) - if sub_response.background: response.background = sub_response.background From 58d1bd5b6b0fda737ee77b43a432efb5e925ee5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Feb 2022 21:20:17 +0000 Subject: [PATCH 07/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strawberry/asgi/handlers/http_handler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index b97266117b..01e46e7bcc 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -1,5 +1,4 @@ import json -import warnings from typing import Any, Callable, Dict, Iterable, Optional from starlette import status From 4f83daec9c4dad42c8bf1bcfd8dfe38f991ad07b Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 2 Feb 2022 14:21:56 -0800 Subject: [PATCH 08/18] Fix missing headers extend --- strawberry/asgi/handlers/http_handler.py | 2 ++ strawberry/types/info.py | 1 + 2 files changed, 3 insertions(+) diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index 01e46e7bcc..a5a8fb2dbb 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -53,6 +53,8 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): context=context, ) + response.headers.raw.extend(sub_response.headers.raw) + if sub_response.background: response.background = sub_response.background diff --git a/strawberry/types/info.py b/strawberry/types/info.py index 3c8d3840b6..a172c04aa1 100644 --- a/strawberry/types/info.py +++ b/strawberry/types/info.py @@ -41,6 +41,7 @@ def field_nodes(self) -> List[FieldNode]: # deprecated "`info.field_nodes` is deprecated, use `selected_fields` instead", DeprecationWarning, ) + return self._raw_info.field_nodes @cached_property From b97a33a38fcb63180c4a59499c9148bdc650abd0 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Sun, 15 May 2022 15:02:47 -0500 Subject: [PATCH 09/18] Remove upper dependency limit for starlette --- pyproject.toml | 2 +- strawberry/asgi/handlers/http_handler.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f79b34e1fd..e8970eb42b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ build-backend = "poetry.masonry.api" [tool.poetry.dependencies] python = "^3.7" -starlette = {version = ">=0.13.6,<0.19.0", optional = true} +starlette = {version = ">=0.13.6", optional = true} click = {version = ">=7.0,<9.0", optional = true} pygments = "^2.3" uvicorn = {version = ">=0.11.6,<0.18.0", optional = true} diff --git a/strawberry/asgi/handlers/http_handler.py b/strawberry/asgi/handlers/http_handler.py index a5a8fb2dbb..3e1fef71da 100644 --- a/strawberry/asgi/handlers/http_handler.py +++ b/strawberry/asgi/handlers/http_handler.py @@ -40,7 +40,7 @@ async def handle(self, scope: Scope, receive: Receive, send: Send): root_value = await self.get_root_value(request) sub_response = Response() - sub_response.status_code = None # typing: ignore + sub_response.status_code = None # type: ignore del sub_response.headers["content-length"] context = await self.get_context(request=request, response=sub_response) From 593d454d858c5969855f8030ed14e8221f204bc0 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:10:26 -0500 Subject: [PATCH 10/18] enable tests for more versions of starlette --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fef6d85ea3..eecfa55f02 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,8 +120,7 @@ jobs: starlette-unit-tests: strategy: matrix: - # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] - starlette: ["0.17.1"] + starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] name: Starlette ${{ matrix.starlette }} runs-on: ubuntu-latest From 084bb44520773a931fa4ceea3cbe5f9b737eb224 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:14:34 -0500 Subject: [PATCH 11/18] Remove stale type ignore --- strawberry/fastapi/router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strawberry/fastapi/router.py b/strawberry/fastapi/router.py index baaccc6b32..4f7f4e6d6d 100644 --- a/strawberry/fastapi/router.py +++ b/strawberry/fastapi/router.py @@ -251,7 +251,7 @@ def pick_preferred_protocol(self, ws: WebSocket) -> Optional[str]: intersection = set(protocols) & set(self.protocols) return min( intersection, - key=lambda i: protocols.index(i), # type: ignore + key=lambda i: protocols.index(i), default=None, ) From 95095ee50a9454769852fa34e8cf14af49349cc8 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:24:13 -0500 Subject: [PATCH 12/18] Fix typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eecfa55f02..f71ab1f62b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -138,7 +138,7 @@ jobs: - run: poetry install if: steps.setup-python.outputs.cache-hit != 'true' - - name: Install django ${{ matrix.starlette }} + - name: Install starlette ${{ matrix.starlette }} run: poetry add --python ^3.10 starlette@^${{ matrix.starlette }} - name: pytest From 2485700fd72630b8ad9f9ec4f80cb182d18d5e17 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:27:46 -0500 Subject: [PATCH 13/18] Disable test on starlette 0.20.0 --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f71ab1f62b..7395dc2847 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,9 @@ jobs: starlette-unit-tests: strategy: matrix: - starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] + # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] + # fastapi doesn't support starlette 0.20.0 just yet + starlette: ["0.17.1", "0.18.0", "0.19.1"] name: Starlette ${{ matrix.starlette }} runs-on: ubuntu-latest From 9d1d56f7c66b1cf28bac131a0ed152ca51e392bb Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:30:21 -0500 Subject: [PATCH 14/18] Add release file --- RELEASE.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..a47b35bba1 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,7 @@ +Release type: minor + +This release adds support for Starlette 0.18 and 0.19 + +It also removes upper bound dependencies limit for starlette, +allowing you to install the latest version without having to +wait for a new release of Strawberry From 8d553f79f72b89c4e1db3a307c73217414822ccb Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:31:51 -0500 Subject: [PATCH 15/18] Remove fastapi in starlette tests --- .github/workflows/test.yml | 7 ++++--- tests/asgi/conftest.py | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7395dc2847..15dc85312d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,9 +120,7 @@ jobs: starlette-unit-tests: strategy: matrix: - # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] - # fastapi doesn't support starlette 0.20.0 just yet - starlette: ["0.17.1", "0.18.0", "0.19.1"] + starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] name: Starlette ${{ matrix.starlette }} runs-on: ubuntu-latest @@ -140,6 +138,9 @@ jobs: - run: poetry install if: steps.setup-python.outputs.cache-hit != 'true' + # this allows us to test on any version of starlette + - name: Remove fastapi + run: poetry remove fastapi --dev - name: Install starlette ${{ matrix.starlette }} run: poetry add --python ^3.10 starlette@^${{ matrix.starlette }} diff --git a/tests/asgi/conftest.py b/tests/asgi/conftest.py index 6f97e6633c..de8cd8a279 100644 --- a/tests/asgi/conftest.py +++ b/tests/asgi/conftest.py @@ -38,14 +38,12 @@ def graphql_client(test_client): def pytest_collection_modifyitems(config, items): - # automatically mark tests with 'starlette' if - # they are in the asgi or fastapi subfolder + # automatically mark tests with 'starlette' if they are in the asgi subfolder rootdir = pathlib.Path(config.rootdir) for item in items: rel_path = pathlib.Path(item.fspath).relative_to(rootdir) - p = str(rel_path) - if p.startswith("tests/asgi") or p.startswith("tests/fastapi"): + if str(rel_path).startswith("tests/asgi"): item.add_marker(pytest.mark.starlette) From 0bb52906678ad0936c929fa65ba7b5256e80f758 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Wed, 18 May 2022 22:41:48 -0500 Subject: [PATCH 16/18] Revert "Remove fastapi in starlette tests" This reverts commit 8d553f79f72b89c4e1db3a307c73217414822ccb. --- .github/workflows/test.yml | 7 +++---- tests/asgi/conftest.py | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15dc85312d..7395dc2847 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,9 @@ jobs: starlette-unit-tests: strategy: matrix: - starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] + # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] + # fastapi doesn't support starlette 0.20.0 just yet + starlette: ["0.17.1", "0.18.0", "0.19.1"] name: Starlette ${{ matrix.starlette }} runs-on: ubuntu-latest @@ -138,9 +140,6 @@ jobs: - run: poetry install if: steps.setup-python.outputs.cache-hit != 'true' - # this allows us to test on any version of starlette - - name: Remove fastapi - run: poetry remove fastapi --dev - name: Install starlette ${{ matrix.starlette }} run: poetry add --python ^3.10 starlette@^${{ matrix.starlette }} diff --git a/tests/asgi/conftest.py b/tests/asgi/conftest.py index de8cd8a279..6f97e6633c 100644 --- a/tests/asgi/conftest.py +++ b/tests/asgi/conftest.py @@ -38,12 +38,14 @@ def graphql_client(test_client): def pytest_collection_modifyitems(config, items): - # automatically mark tests with 'starlette' if they are in the asgi subfolder + # automatically mark tests with 'starlette' if + # they are in the asgi or fastapi subfolder rootdir = pathlib.Path(config.rootdir) for item in items: rel_path = pathlib.Path(item.fspath).relative_to(rootdir) + p = str(rel_path) - if str(rel_path).startswith("tests/asgi"): + if p.startswith("tests/asgi") or p.startswith("tests/fastapi"): item.add_marker(pytest.mark.starlette) From a5c9de5c82b886923e40315f71bc7e0234f9f175 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Thu, 19 May 2022 11:17:03 -0500 Subject: [PATCH 17/18] Try installing starlette via pip --- .github/workflows/test.yml | 6 ++---- tests/asgi/conftest.py | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7395dc2847..1c8730076c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,9 +120,7 @@ jobs: starlette-unit-tests: strategy: matrix: - # starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] - # fastapi doesn't support starlette 0.20.0 just yet - starlette: ["0.17.1", "0.18.0", "0.19.1"] + starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"] name: Starlette ${{ matrix.starlette }} runs-on: ubuntu-latest @@ -141,7 +139,7 @@ jobs: if: steps.setup-python.outputs.cache-hit != 'true' - name: Install starlette ${{ matrix.starlette }} - run: poetry add --python ^3.10 starlette@^${{ matrix.starlette }} + run: poetry run pip install starlette==${{ matrix.starlette }} - name: pytest run: diff --git a/tests/asgi/conftest.py b/tests/asgi/conftest.py index 6f97e6633c..de8cd8a279 100644 --- a/tests/asgi/conftest.py +++ b/tests/asgi/conftest.py @@ -38,14 +38,12 @@ def graphql_client(test_client): def pytest_collection_modifyitems(config, items): - # automatically mark tests with 'starlette' if - # they are in the asgi or fastapi subfolder + # automatically mark tests with 'starlette' if they are in the asgi subfolder rootdir = pathlib.Path(config.rootdir) for item in items: rel_path = pathlib.Path(item.fspath).relative_to(rootdir) - p = str(rel_path) - if p.startswith("tests/asgi") or p.startswith("tests/fastapi"): + if str(rel_path).startswith("tests/asgi"): item.add_marker(pytest.mark.starlette) From 10b411ff1ce1a9d80832e6e6c471c5648a206396 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Thu, 19 May 2022 11:25:20 -0500 Subject: [PATCH 18/18] Update RELEASE.md --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index a47b35bba1..f74230bb71 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,6 @@ Release type: minor -This release adds support for Starlette 0.18 and 0.19 +This release adds support for Starlette 0.18 to 0.20 It also removes upper bound dependencies limit for starlette, allowing you to install the latest version without having to