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

Some more typing for Request/Response classes #2205

Closed
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions falcon/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

from datetime import datetime
from io import BytesIO
import sys
from uuid import UUID

if sys.version_info >= (3, 11):
from wsgiref.types import InputStream

Check warning on line 21 in falcon/request.py

View check run for this annotation

Codecov / codecov/patch

falcon/request.py#L21

Added line #L21 was not covered by tests

from falcon import errors
from falcon import request_helpers as helpers
from falcon import util
Expand Down Expand Up @@ -454,6 +458,9 @@
# Child classes may override this
context_type = structures.Context

if sys.version_info >= (3, 11):
stream: InputStream

Check warning on line 462 in falcon/request.py

View check run for this annotation

Codecov / codecov/patch

falcon/request.py#L462

Added line #L462 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IO[bytest] imported from typing.


_wsgi_input_type_known = False

def __init__(self, env, options=None):
Expand Down
5 changes: 4 additions & 1 deletion falcon/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class Response:
# Child classes may override this
context_type = structures.Context

text: Optional[str]
_data: Optional[bytes]

def __init__(self, options=None):
self.status = '200 OK'
self._headers = {}
Expand Down Expand Up @@ -227,7 +230,7 @@ def data(self):
return self._data

@data.setter
def data(self, value):
def data(self, value: bytes):
self._data = value

@property
Expand Down
Loading