Skip to content

Commit 01308ee

Browse files
committed
add spacing and semi black formatting
1 parent b2a3833 commit 01308ee

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

httptools/parser/parser.pyi

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from typing import Union, Any
2-
from array import array
2+
from array import array
33
from .protocol import HTTPProtocol
44

5-
6-
75
class HttpParser:
8-
def __init__(self, protocol:Union[HTTPProtocol, Any]) -> None:
6+
def __init__(self, protocol: Union[HTTPProtocol, Any]) -> None:
97
"""
108
protocol -- a Python object with the following methods
119
(all optional):
@@ -24,15 +22,18 @@ class HttpParser:
2422
def get_http_version(self) -> str:
2523
"""Return an HTTP protocol version."""
2624
...
25+
2726
def should_keep_alive(self) -> bool:
2827
"""Return ``True`` if keep-alive mode is preferred."""
2928
...
29+
3030
def should_upgrade(self) -> bool:
3131
"""Return ``True`` if the parsed request is a valid Upgrade request.
32-
The method exposes a flag set just before on_headers_complete.
33-
Calling this method earlier will only yield `False`."""
32+
The method exposes a flag set just before on_headers_complete.
33+
Calling this method earlier will only yield `False`."""
3434
...
35-
def feed_data(self, data:Union[bytes, bytearray, memoryview, array]) -> None:
35+
36+
def feed_data(self, data: Union[bytes, bytearray, memoryview, array]) -> None:
3637
"""Feed data to the parser.
3738
3839
Will eventually trigger callbacks on the ``protocol``
@@ -43,14 +44,12 @@ class HttpParser:
4344
set to the offset of the non-HTTP data in ``data``.
4445
"""
4546

46-
4747
class HttpRequestParser(HttpParser):
4848
"""Used for parsing http requests from the server's side"""
49-
49+
5050
def get_method(self) -> bytes:
5151
"""Return HTTP request method (GET, HEAD, etc)"""
5252

53-
5453
class HttpResponseParser(HttpParser):
5554
"""Used for parsing http requests from the client's side"""
5655

httptools/parser/protocol.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from typing import Protocol
22

3+
34
class HTTPProtocol(Protocol):
45
"""Used for providing static type-checking when parsing through the http protocol"""
56

6-
def on_message_begin() -> None:...
7-
def on_url(url: bytes) -> None:...
8-
def on_header(name: bytes, value: bytes) -> None:...
9-
def on_headers_complete() -> None:...
10-
def on_body(body: bytes) -> None:...
11-
def on_message_complete() -> None:...
12-
def on_chunk_header() -> None:...
13-
def on_chunk_complete() -> None:...
14-
def on_status(status: bytes) -> None:...
15-
7+
def on_message_begin() -> None: ...
8+
def on_url(url: bytes) -> None: ...
9+
def on_header(name: bytes, value: bytes) -> None: ...
10+
def on_headers_complete() -> None: ...
11+
def on_body(body: bytes) -> None: ...
12+
def on_message_complete() -> None: ...
13+
def on_chunk_header() -> None: ...
14+
def on_chunk_complete() -> None: ...
15+
def on_status(status: bytes) -> None: ...

httptools/parser/url_parser.pyi

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ from typing import Union
22
from array import array
33

44
class URL:
5-
schema:bytes
6-
host:bytes
7-
port:int
8-
path:bytes
9-
query:bytes
10-
fragment:bytes
11-
userinfo:bytes
5+
schema: bytes
6+
host: bytes
7+
port: int
8+
path: bytes
9+
query: bytes
10+
fragment: bytes
11+
userinfo: bytes
1212

13-
def parse_url(url:Union[bytes, bytearray, memoryview, array]) -> URL:
13+
def parse_url(url: Union[bytes, bytearray, memoryview, array]) -> URL:
1414
"""Parse URL strings into a structured Python object.
1515
1616
Returns an instance of ``httptools.URL`` class with the
@@ -25,5 +25,3 @@ def parse_url(url:Union[bytes, bytearray, memoryview, array]) -> URL:
2525
- userinfo: bytes
2626
"""
2727
...
28-
29-

0 commit comments

Comments
 (0)