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

feat: type more falcon modules #2171

Merged
merged 58 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a4093e4
feat: Type app helpers module
copalco Aug 16, 2023
9752b23
feat: Add typing to errors module
copalco Aug 16, 2023
8843cb5
feat: Add typings to forwarded module
copalco Aug 16, 2023
5f80341
feat: Add typing to hooks
copalco Aug 18, 2023
1f52765
feat: Add typing to falcon hooks
copalco Aug 18, 2023
084c327
feat: Add typing to http_error module
copalco Aug 18, 2023
0797b3d
feat: Extract RawHeaders and NormalizedHeaders to typing module
copalco Aug 18, 2023
af73715
feat: Extract status to typing module
copalco Aug 18, 2023
23d03df
feat: Add typing to http_status module
copalco Aug 18, 2023
c0aaf47
feat: Add typing to inspect module
copalco Aug 18, 2023
1697003
feat: Add typing to middleware module
copalco Aug 18, 2023
0bf142e
feat: Replace protocol with interface
copalco Aug 19, 2023
7a07eaa
feat: Add typing to redirects
copalco Aug 19, 2023
01338e3
feat: Type vendor mimeparse
copalco Aug 20, 2023
5abe369
Changed RawHeaders to not include None
copalco Aug 24, 2023
7e30e48
Reformated imports
copalco Aug 24, 2023
ec48fb5
Test that interface raises not implemented
copalco Aug 24, 2023
44f4487
Type algorithm int values as float
copalco Aug 24, 2023
9822048
Changed allowed methods to Iterable
copalco Aug 24, 2023
2630826
Imported annotations in hooks
copalco Aug 24, 2023
9046af3
Change argnames type to list of strings
copalco Aug 24, 2023
729d3d1
Changed Dict to mutable mapping
copalco Aug 24, 2023
75baaf5
Fixed formatting
copalco Aug 24, 2023
1a1a115
Remove unused imports
copalco Aug 24, 2023
6703a2e
Fix typing
copalco Aug 24, 2023
37b821f
Replaced assert with cast
copalco Aug 24, 2023
491fc90
Fix blue
copalco Aug 24, 2023
d277180
Type resource as object
copalco Aug 24, 2023
a0a4110
Fix style
copalco Aug 24, 2023
aed01aa
Revert "Type algorithm int values as float"
copalco Aug 29, 2023
42236b6
Revert "feat: Type vendor mimeparse"
copalco Aug 29, 2023
659b863
Ignore vendore package
copalco Aug 30, 2023
c074212
Use async package instead of importing AsyncRequest and AsyncResponse…
copalco Aug 30, 2023
aa5321a
Solve circular imports while typing
copalco Aug 30, 2023
ff1d995
Fix style
copalco Aug 30, 2023
a50fd3e
Changed inspect obj type to Any
copalco Aug 31, 2023
79d7093
Import annotations where missing
copalco Sep 4, 2023
f844071
Replace Union with | where future annotations imported
copalco Sep 6, 2023
8b06f45
Revert "Replace Union with | where future annotations imported"
copalco Sep 6, 2023
08f78e9
Improve imports to avoid them inside functions
CaselIT Sep 9, 2023
1317945
Fix typo
copalco Oct 16, 2023
5de1831
Rename Kwargs to HTTPErrorKeywordArgs
copalco Oct 16, 2023
d78d57b
Import whole package insted of specific types
copalco Oct 16, 2023
6d4882d
Fix style
copalco Oct 17, 2023
6ad28c4
Replace Serializer and MediaHandler with protocol
copalco Oct 17, 2023
cd35341
Add assertion reason message
copalco Oct 27, 2023
14909a7
Fix import issue
copalco Oct 29, 2023
208c809
Fix import order
copalco Oct 30, 2023
f06d56b
Fix coverage issues
copalco Nov 5, 2023
cf3fce0
Add ResponderOrResource and Action types
copalco Nov 5, 2023
ff70cd3
Merge branch 'master' into copalco/master
CaselIT Aug 11, 2024
bf887eb
style: run ruff
CaselIT Aug 11, 2024
af41e56
typing: apply review feedmack
CaselIT Aug 11, 2024
7bd3ea6
typing: avoid protocols for handlers
CaselIT Aug 11, 2024
bd92613
typing: improve type alias name
CaselIT Aug 11, 2024
8a4b380
Merge branch 'master' into types_pr2171
CaselIT Aug 11, 2024
3dcb5df
Merge branch 'master' into master
vytas7 Aug 11, 2024
e630a2e
fix: restore support to python 3.8 and 3.7
CaselIT Aug 11, 2024
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
2 changes: 1 addition & 1 deletion falcon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def add_static_route(
self._static_routes.insert(0, (sr, sr, False))
self._update_sink_and_static_routes()

def add_sink(self, sink: Callable, prefix: SinkPrefix = r'/'):
def add_sink(self, sink: Callable, prefix: SinkPrefix = r'/') -> None:
"""Register a sink method for the App.

If no route matches a request, but the path in the requested URI
Expand Down
12 changes: 7 additions & 5 deletions falcon/app_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

"""Utilities for the App class."""

from __future__ import annotations

from inspect import iscoroutinefunction
from typing import IO, Iterable, List, Tuple

Expand Down Expand Up @@ -202,7 +204,7 @@ def prepare_middleware_ws(middleware: Iterable) -> Tuple[list, list]:
return request_mw, resource_mw


def default_serialize_error(req: Request, resp: Response, exception: HTTPError):
def default_serialize_error(req: Request, resp: Response, exception: HTTPError) -> None:
"""Serialize the given instance of HTTPError.

This function determines which of the supported media types, if
Expand Down Expand Up @@ -281,22 +283,22 @@ class CloseableStreamIterator:
block_size (int): Number of bytes to read per iteration.
"""

def __init__(self, stream: IO, block_size: int):
def __init__(self, stream: IO, block_size: int) -> None:
CaselIT marked this conversation as resolved.
Show resolved Hide resolved
self._stream = stream
self._block_size = block_size

def __iter__(self):
def __iter__(self) -> CloseableStreamIterator:
return self

def __next__(self):
def __next__(self) -> bytes:
data = self._stream.read(self._block_size)

if data == b'':
raise StopIteration
else:
return data

def close(self):
def close(self) -> None:
try:
self._stream.close()
except (AttributeError, TypeError):
Expand Down
2 changes: 2 additions & 0 deletions falcon/asgi_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

"""Constants, etc. defined by the ASGI specification."""

from __future__ import annotations
CaselIT marked this conversation as resolved.
Show resolved Hide resolved


class EventType:
"""Standard ASGI event type strings."""
Expand Down
Loading
Loading