Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with starlette 0.18.0 and above #1594

Merged
merged 18 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ jobs:
strategy:
matrix:
# starlette: ["0.17.1", "0.18.0", "0.19.1", "0.20.0"]
starlette: ["0.17.1"]
# 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
Expand All @@ -139,7 +140,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
Expand Down
7 changes: 7 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Release type: minor

This release adds support for Starlette 0.18 and 0.19
patrick91 marked this conversation as resolved.
Show resolved Hide resolved

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
28 changes: 14 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", optional = true}
click = {version = ">=7.0,<9.0", optional = true}
pygments = "^2.3"
uvicorn = {version = ">=0.11.6,<0.18.0", optional = true}
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 3 additions & 7 deletions strawberry/asgi/handlers/http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ 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()
sub_response.status_code = None # type: ignore
del sub_response.headers["content-length"]

context = await self.get_context(request=request, response=sub_response)

Expand Down
2 changes: 1 addition & 1 deletion strawberry/fastapi/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
1 change: 1 addition & 0 deletions strawberry/types/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def field_nodes(self) -> List[FieldNode]: # deprecated
"`info.field_nodes` is deprecated, use `selected_fields` instead",
DeprecationWarning,
)

patrick91 marked this conversation as resolved.
Show resolved Hide resolved
return self._raw_info.field_nodes

@cached_property
Expand Down