Skip to content

Commit 0762992

Browse files
committed
[Update] formatting
1 parent 61ddd79 commit 0762992

File tree

15 files changed

+72
-38
lines changed

15 files changed

+72
-38
lines changed

examples/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Default: https://google.com/
2323
"""
2424

25+
2526
async def make_requests(url_str: str, num_requests: int = 3):
2627
"""Make multiple HTTP requests to demonstrate connection pooling."""
2728
uri = URI.Parse(url_str)

examples/htmx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ def html_page(self, *body_content: Node) -> str:
3434
H.head(
3535
H.title("HTMX Example"),
3636
H.script(src="https://unpkg.com/htmx.org@1.9.12"),
37-
H.style("""
37+
H.style(
38+
"""
3839
body { font-family: Arial, sans-serif; padding: 20px; }
3940
.counter { font-size: 24px; margin: 10px 0; }
4041
button { padding: 10px 20px; margin: 5px; cursor: pointer; }
41-
"""),
42+
"""
43+
),
4244
),
4345
H.body(*body_content),
4446
)

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "extra-http"
7-
version = "1.0.2"
7+
version = "1.0.3"
88
description = "A fast, async HTTP framework"
99
readme = "README.md"
1010
requires-python = ">=3.10"
@@ -45,10 +45,15 @@ where = ["src/py"]
4545
[tool.ruff]
4646
line-length = 88
4747
target-version = "py38"
48+
indent-width = 4
49+
50+
[tool.ruff.format]
51+
quote-style = "double"
52+
indent-style = "tab"
4853

4954
[tool.ruff.lint]
5055
select = ["E", "F", "W", "I"]
51-
ignore = ["E203", "E501", "W503"]
56+
ignore = ["E203", "E501"]
5257

5358
[tool.mypy]
5459
python_version = "3.10"
@@ -59,4 +64,4 @@ disallow_untyped_defs = true
5964
[tool.bandit]
6065
exclude_dirs = ["tests", "build"]
6166
skips = ["B101"]
62-
# EOF
67+
# EOF

src/py/extra/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from .http.parser import HTTPParser
2626

2727
# For Python 3.8 compatibility
28-
ConnectionT = TypeVar('ConnectionT', bound='Connection')
29-
ConnectionPoolT = TypeVar('ConnectionPoolT', bound='ConnectionPool')
28+
ConnectionT = TypeVar("ConnectionT", bound="Connection")
29+
ConnectionPoolT = TypeVar("ConnectionPoolT", bound="ConnectionPool")
3030

3131

3232
# --

src/py/extra/decorators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ def decorator(function: T) -> T:
129129
meta.setdefault(Extra.ON_PRIORITY, int(priority))
130130
json_data: Union[Any, None] = None
131131
for http_method, url in list(methods.items()):
132-
urls: Union[list[str], tuple[str, ...]] = (url,) if isinstance(url, str) else url
132+
urls: Union[list[str], tuple[str, ...]] = (
133+
(url,) if isinstance(url, str) else url
134+
)
133135
for method in http_method.upper().split("_"):
134136
for _ in urls:
135137
if method == "JSON":

src/py/extra/handler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
# - `authorizer`: (If applicable) Information from a custom authorizer (e.g., Lambda authorizer) that you've configured for your API Gateway API.
7777

7878

79-
TAWSRequestContext = dict[str, Union[str, bytes, int, float, bool, dict[str, str], None]]
79+
TAWSRequestContext = dict[
80+
str, Union[str, bytes, int, float, bool, dict[str, str], None]
81+
]
8082
TAWSEvent = dict[
8183
str, Union[str, bytes, int, float, bool, dict[str, str], TAWSRequestContext, None]
8284
]
@@ -195,7 +197,9 @@ async def handle(
195197
self, event: dict[str, Any], context: Union[dict[str, Any], None] = None
196198
) -> dict[str, Any]:
197199
req: HTTPRequest = AWSLambdaEvent.AsRequest(event)
198-
r: Union[HTTPResponse, Coroutine[Any, HTTPResponse, Any]] = self.app.process(req)
200+
r: Union[HTTPResponse, Coroutine[Any, HTTPResponse, Any]] = self.app.process(
201+
req
202+
)
199203
if isinstance(r, HTTPResponse):
200204
res: HTTPResponse = r
201205
else:
@@ -241,7 +245,9 @@ def event(
241245

242246

243247
def awslambda(
244-
handler: Callable[[HTTPRequest], Union[HTTPResponse, Coroutine[Any, HTTPResponse, Any]]],
248+
handler: Callable[
249+
[HTTPRequest], Union[HTTPResponse, Coroutine[Any, HTTPResponse, Any]]
250+
],
245251
) -> Callable[[dict[str, Any], Union[dict[str, Any], None]], dict[str, Any]]:
246252
def wrapper(
247253
event: dict[str, Any], context: Union[dict[str, Any], None] = None

src/py/extra/http/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def respond(
3333
status: int = 200,
3434
headers: dict[str, str] | None = None,
3535
message: str | None = None,
36-
) -> T: ...
36+
) -> T:
37+
...
3738

3839
def error(
3940
self,

src/py/extra/http/model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ async def read(
313313
@abstractmethod
314314
async def _read(
315315
self, timeout: float = BODY_READER_TIMEOUT, size: int | None = None
316-
) -> bytes | None: ...
316+
) -> bytes | None:
317+
...
317318

318319
# NOTE: This is a dangerous operation, as this way bloat the whole memory.
319320
# Instead, loading should spool the file.
@@ -425,7 +426,8 @@ async def _write(self, chunk: bytes, more: bool = False) -> bool:
425426
@abstractmethod
426427
async def _writeBytes(
427428
self, chunk: bytes | None | Literal[False], more: bool = False
428-
) -> bool: ...
429+
) -> bool:
430+
...
429431

430432

431433
# -----------------------------------------------------------------------------
@@ -534,7 +536,7 @@ def onClose(
534536
self._onClose = callback
535537
return self
536538

537-
async def read(self) -> AsyncGenerator[bytes | None]:
539+
async def read(self) -> AsyncGenerator[bytes | None, None]:
538540
body = self.body
539541
if isinstance(body, HTTPBodyBlob):
540542
yield body.raw

src/py/extra/http/processors.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515

1616
class Processor(ABC, Generic[T]):
1717
@abstractmethod
18-
def accepts(self, headers: dict[str, str]) -> bool: ...
18+
def accepts(self, headers: dict[str, str]) -> bool:
19+
...
1920

2021
@abstractmethod
21-
def start(self, headers: dict[str, str]) -> int: ...
22+
def start(self, headers: dict[str, str]) -> int:
23+
...
2224

2325
@abstractmethod
24-
def feed(self, chunk: bytes) -> T | Control: ...
26+
def feed(self, chunk: bytes) -> T | Control:
27+
...
2528

2629

2730
# -----------------------------------------------------------------------------

src/py/extra/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def ReloadFrom(cls, service: "Service") -> "Service":
3434
# TODO: What about the prefix?
3535
return res
3636

37-
def __init__(self, name: Union[str, None] = None, *, prefix: Union[str, None] = None) -> None:
37+
def __init__(
38+
self, name: Union[str, None] = None, *, prefix: Union[str, None] = None
39+
) -> None:
3840
self.name: str = name or self.__class__.__name__
3941
self.app: Union[Application, None] = None
4042
self.prefix = prefix or self.PREFIX

0 commit comments

Comments
 (0)