Skip to content

Commit

Permalink
Revert import changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FurqanHabibi committed Sep 26, 2024
1 parent cb6c3f2 commit 2dbf7e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
11 changes: 6 additions & 5 deletions mangum/adapter.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import logging
from contextlib import ExitStack
from itertools import chain
from contextlib import ExitStack
from typing import List, Optional, Type

from mangum.exceptions import ConfigurationError
from mangum.handlers import ALB, APIGateway, HTTPGateway, LambdaAtEdge
from mangum.protocols import HTTPCycle, LifespanCycle
from mangum.handlers import ALB, HTTPGateway, APIGateway, LambdaAtEdge
from mangum.exceptions import ConfigurationError
from mangum.types import (
ASGI,
LifespanMode,
LambdaConfig,
LambdaContext,
LambdaEvent,
LambdaContext,
LambdaHandler,
LifespanMode,
)


logger = logging.getLogger("mangum")


Expand Down
12 changes: 3 additions & 9 deletions mangum/protocols/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging
from io import BytesIO

from mangum.types import ASGI, Message, Scope, Response
from mangum.exceptions import UnexpectedMessage
from mangum.types import ASGI, Message, Response, Scope


class HTTPCycleState(enum.Enum):
Expand Down Expand Up @@ -82,17 +82,11 @@ async def receive(self) -> Message:
return await self.app_queue.get() # pragma: no cover

async def send(self, message: Message) -> None:
if (
self.state is HTTPCycleState.REQUEST
and message["type"] == "http.response.start"
):
if self.state is HTTPCycleState.REQUEST and message["type"] == "http.response.start":
self.status = message["status"]
self.headers = message.get("headers", [])
self.state = HTTPCycleState.RESPONSE
elif (
self.state is HTTPCycleState.RESPONSE
and message["type"] == "http.response.body"
):
elif self.state is HTTPCycleState.RESPONSE and message["type"] == "http.response.body":
body = message.get("body", b"")
more_body = message.get("more_body", False)
self.buffer.write(body)
Expand Down
2 changes: 1 addition & 1 deletion mangum/protocols/lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from types import TracebackType
from typing import Any, Dict, Optional, Type

from mangum.exceptions import LifespanFailure, LifespanUnsupported, UnexpectedMessage
from mangum.types import ASGI, LifespanMode, Message
from mangum.exceptions import LifespanUnsupported, LifespanFailure, UnexpectedMessage


class LifespanCycleState(enum.Enum):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_lifespan.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import logging

import pytest
from quart import Quart

from starlette.applications import Starlette
from starlette.responses import PlainTextResponse

from mangum import Mangum
from mangum.exceptions import LifespanFailure

from quart import Quart


@pytest.mark.parametrize(
"mock_aws_api_gateway_event,lifespan",
Expand Down

0 comments on commit 2dbf7e8

Please sign in to comment.