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

⬆ Upgrade Starlette from 0.19.1 to 0.20.4 #5355

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion fastapi/applications.py
Expand Up @@ -33,9 +33,10 @@
from fastapi.utils import generate_unique_id
from starlette.applications import Starlette
from starlette.datastructures import State
from starlette.exceptions import ExceptionMiddleware, HTTPException
from starlette.exceptions import HTTPException
from starlette.middleware import Middleware
from starlette.middleware.errors import ServerErrorMiddleware
from starlette.middleware.exceptions import ExceptionMiddleware
from starlette.requests import Request
from starlette.responses import HTMLResponse, JSONResponse, Response
from starlette.routing import BaseRoute
Expand Down
11 changes: 2 additions & 9 deletions fastapi/concurrency.py
@@ -1,4 +1,5 @@
import sys
from contextlib import AsyncExitStack as AsyncExitStack # noqa
from contextlib import asynccontextmanager as asynccontextmanager
from typing import AsyncGenerator, ContextManager, TypeVar

import anyio
Expand All @@ -9,14 +10,6 @@
run_until_first_complete as run_until_first_complete,
)

if sys.version_info >= (3, 7):
from contextlib import AsyncExitStack as AsyncExitStack
from contextlib import asynccontextmanager as asynccontextmanager
else:
from contextlib2 import AsyncExitStack as AsyncExitStack # noqa
from contextlib2 import asynccontextmanager as asynccontextmanager # noqa


_T = TypeVar("_T")


Expand Down
3 changes: 2 additions & 1 deletion fastapi/dependencies/utils.py
Expand Up @@ -7,6 +7,7 @@
Callable,
Coroutine,
Dict,
ForwardRef,
List,
Mapping,
Optional,
Expand Down Expand Up @@ -47,7 +48,7 @@
Undefined,
)
from pydantic.schema import get_annotation_from_field_info
from pydantic.typing import ForwardRef, evaluate_forwardref
from pydantic.typing import evaluate_forwardref
from pydantic.utils import lenient_issubclass
from starlette.background import BackgroundTasks
from starlette.concurrency import run_in_threadpool
Expand Down
4 changes: 2 additions & 2 deletions fastapi/encoders.py
Expand Up @@ -54,8 +54,8 @@ def jsonable_encoder(
if custom_encoder:
encoder.update(custom_encoder)
obj_dict = obj.dict(
include=include, # type: ignore # in Pydantic
exclude=exclude, # type: ignore # in Pydantic
include=include,
exclude=exclude,
by_alias=by_alias,
exclude_unset=exclude_unset,
exclude_none=exclude_none,
Expand Down
2 changes: 1 addition & 1 deletion fastapi/security/api_key.py
Expand Up @@ -27,7 +27,7 @@ def __init__(
self.auto_error = auto_error

async def __call__(self, request: Request) -> Optional[str]:
api_key: str = request.query_params.get(self.model.name)
api_key = request.query_params.get(self.model.name)
if not api_key:
if self.auto_error:
raise HTTPException(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -35,7 +35,7 @@ classifiers = [
"Topic :: Internet :: WWW/HTTP",
]
requires = [
"starlette==0.19.1",
"starlette==0.20.4",
"pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0",
]
description-file = "README.md"
Expand Down
12 changes: 12 additions & 0 deletions tests/test_route_scope.py
Expand Up @@ -12,6 +12,12 @@ async def get_user(user_id: str, request: Request):
return {"user_id": user_id, "path": route.path}


@app.post("/items/{item_id}:move")
async def move_item(item_id: str, request: Request):
route: APIRoute = request.scope["route"]
return {"item_id": item_id, "path": route.path}


@app.websocket("/items/{item_id}")
async def websocket_item(item_id: str, websocket: WebSocket):
route: APIWebSocketRoute = websocket.scope["route"]
Expand All @@ -38,6 +44,12 @@ def test_invalid_path_doesnt_match():
assert response.status_code == 404, response.text


def test_move():
response = client.post("/items/portal-gun:move")
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "portal-gun", "path": "/items/{item_id}:move"}


def test_websocket():
with client.websocket_connect("/items/portal-gun") as websocket:
data = websocket.receive_json()
Expand Down