Skip to content

Commit

Permalink
Start exception descriptions with uppercase letter.
Browse files Browse the repository at this point in the history
This change was automated with regex replaces:

^(    Raises:\n(?:        .*\n(?:            .*\n)*)*?(?:        \w+): )([a-z])
$1\U$2

^(        Raises:\n(?:            .*\n(?:                .*\n)*)*?(?:            \w+): )([a-z])
$1\U$2
  • Loading branch information
aaugustin committed Jan 21, 2024
1 parent c53fc3b commit 2865bdc
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/websockets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def process_response(self, response: Response) -> None:
request: WebSocket handshake response received from the server.
Raises:
InvalidHandshake: if the handshake response is invalid.
InvalidHandshake: If the handshake response is invalid.
"""

Expand Down Expand Up @@ -216,7 +216,7 @@ def process_extensions(self, headers: Headers) -> List[Extension]:
List of accepted extensions.
Raises:
InvalidHandshake: to abort the handshake.
InvalidHandshake: To abort the handshake.
"""
accepted_extensions: List[Extension] = []
Expand Down
6 changes: 3 additions & 3 deletions src/websockets/extensions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def decode(
Decoded frame.
Raises:
PayloadTooBig: if decoding the payload exceeds ``max_size``.
PayloadTooBig: If decoding the payload exceeds ``max_size``.
"""
raise NotImplementedError
Expand Down Expand Up @@ -89,7 +89,7 @@ def process_response_params(
An extension instance.
Raises:
NegotiationError: if parameters aren't acceptable.
NegotiationError: If parameters aren't acceptable.
"""
raise NotImplementedError
Expand Down Expand Up @@ -121,7 +121,7 @@ def process_request_params(
extension and an extension instance.
Raises:
NegotiationError: to reject the offer, if parameters received from
NegotiationError: To reject the offer, if parameters received from
the client aren't acceptable.
"""
Expand Down
22 changes: 11 additions & 11 deletions src/websockets/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ def parse(
extensions: List of extensions, applied in reverse order.
Raises:
EOFError: if the connection is closed without a full WebSocket frame.
UnicodeDecodeError: if the frame contains invalid UTF-8.
PayloadTooBig: if the frame's payload size exceeds ``max_size``.
ProtocolError: if the frame contains incorrect values.
EOFError: If the connection is closed without a full WebSocket frame.
UnicodeDecodeError: If the frame contains invalid UTF-8.
PayloadTooBig: If the frame's payload size exceeds ``max_size``.
ProtocolError: If the frame contains incorrect values.
"""
# Read the header.
Expand Down Expand Up @@ -285,7 +285,7 @@ def serialize(
extensions: List of extensions, applied in order.
Raises:
ProtocolError: if the frame contains incorrect values.
ProtocolError: If the frame contains incorrect values.
"""
self.check()
Expand Down Expand Up @@ -334,7 +334,7 @@ def check(self) -> None:
Check that reserved bits and opcode have acceptable values.
Raises:
ProtocolError: if a reserved bit or the opcode is invalid.
ProtocolError: If a reserved bit or the opcode is invalid.
"""
if self.rsv1 or self.rsv2 or self.rsv3:
Expand All @@ -360,7 +360,7 @@ def prepare_data(data: Data) -> Tuple[int, bytes]:
object.
Raises:
TypeError: if ``data`` doesn't have a supported type.
TypeError: If ``data`` doesn't have a supported type.
"""
if isinstance(data, str):
Expand All @@ -383,7 +383,7 @@ def prepare_ctrl(data: Data) -> bytes:
If ``data`` is a bytes-like object, return a :class:`bytes` object.
Raises:
TypeError: if ``data`` doesn't have a supported type.
TypeError: If ``data`` doesn't have a supported type.
"""
if isinstance(data, str):
Expand Down Expand Up @@ -435,8 +435,8 @@ def parse(cls, data: bytes) -> Close:
data: Payload of the close frame.
Raises:
ProtocolError: if data is ill-formed.
UnicodeDecodeError: if the reason isn't valid UTF-8.
ProtocolError: If data is ill-formed.
UnicodeDecodeError: If the reason isn't valid UTF-8.
"""
if len(data) >= 2:
Expand All @@ -463,7 +463,7 @@ def check(self) -> None:
Check that the close code has a valid value for a close frame.
Raises:
ProtocolError: if the close code is invalid.
ProtocolError: If the close code is invalid.
"""
if not (self.code in EXTERNAL_CLOSE_CODES or 3000 <= self.code < 5000):
Expand Down
30 changes: 15 additions & 15 deletions src/websockets/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def parse_token(header: str, pos: int, header_name: str) -> Tuple[str, int]:
Return the token value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
match = _token_re.match(header, pos)
Expand All @@ -127,7 +127,7 @@ def parse_quoted_string(header: str, pos: int, header_name: str) -> Tuple[str, i
Return the unquoted value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
match = _quoted_string_re.match(header, pos)
Expand Down Expand Up @@ -180,7 +180,7 @@ def parse_list(
Return a list of items.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
# Per https://www.rfc-editor.org/rfc/rfc7230.html#section-7, "a recipient
Expand Down Expand Up @@ -234,7 +234,7 @@ def parse_connection_option(
Return the protocol value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
item, pos = parse_token(header, pos, header_name)
Expand All @@ -251,7 +251,7 @@ def parse_connection(header: str) -> List[ConnectionOption]:
header: value of the ``Connection`` header.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
return parse_list(parse_connection_option, header, 0, "Connection")
Expand All @@ -271,7 +271,7 @@ def parse_upgrade_protocol(
Return the protocol value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
match = _protocol_re.match(header, pos)
Expand All @@ -292,7 +292,7 @@ def parse_upgrade(header: str) -> List[UpgradeProtocol]:
header: Value of the ``Upgrade`` header.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
return parse_list(parse_upgrade_protocol, header, 0, "Upgrade")
Expand All @@ -307,7 +307,7 @@ def parse_extension_item_param(
Return a ``(name, value)`` pair and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
# Extract parameter name.
Expand Down Expand Up @@ -344,7 +344,7 @@ def parse_extension_item(
list of ``(name, value)`` pairs, and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
# Extract extension name.
Expand Down Expand Up @@ -379,7 +379,7 @@ def parse_extension(header: str) -> List[ExtensionHeader]:
Parameter values are :obj:`None` when no value is provided.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
return parse_list(parse_extension_item, header, 0, "Sec-WebSocket-Extensions")
Expand Down Expand Up @@ -431,7 +431,7 @@ def parse_subprotocol_item(
Return the subprotocol value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
item, pos = parse_token(header, pos, header_name)
Expand All @@ -445,7 +445,7 @@ def parse_subprotocol(header: str) -> List[Subprotocol]:
Return a list of WebSocket subprotocols.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
return parse_list(parse_subprotocol_item, header, 0, "Sec-WebSocket-Protocol")
Expand Down Expand Up @@ -505,7 +505,7 @@ def parse_token68(header: str, pos: int, header_name: str) -> Tuple[str, int]:
Return the token value and the new position.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderFormat: On invalid inputs.
"""
match = _token68_re.match(header, pos)
Expand Down Expand Up @@ -535,8 +535,8 @@ def parse_authorization_basic(header: str) -> Tuple[str, str]:
header: Value of the ``Authorization`` header.
Raises:
InvalidHeaderFormat: on invalid inputs.
InvalidHeaderValue: on unsupported inputs.
InvalidHeaderFormat: On invalid inputs.
InvalidHeaderValue: On unsupported inputs.
"""
# https://www.rfc-editor.org/rfc/rfc7235.html#section-2.1
Expand Down
24 changes: 12 additions & 12 deletions src/websockets/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def parse(
line or raises an exception if there isn't enough data
Raises:
EOFError: if the connection is closed without a full HTTP request.
SecurityError: if the request exceeds a security limit.
ValueError: if the request isn't well formatted.
EOFError: If the connection is closed without a full HTTP request.
SecurityError: If the request exceeds a security limit.
ValueError: If the request isn't well formatted.
"""
# https://www.rfc-editor.org/rfc/rfc7230.html#section-3.1.1
Expand Down Expand Up @@ -201,10 +201,10 @@ def parse(
of the stream.
Raises:
EOFError: if the connection is closed without a full HTTP response.
SecurityError: if the response exceeds a security limit.
LookupError: if the response isn't well formatted.
ValueError: if the response isn't well formatted.
EOFError: If the connection is closed without a full HTTP response.
SecurityError: If the response exceeds a security limit.
LookupError: If the response isn't well formatted.
ValueError: If the response isn't well formatted.
"""
# https://www.rfc-editor.org/rfc/rfc7230.html#section-3.1.2
Expand Down Expand Up @@ -299,9 +299,9 @@ def parse_headers(
or raises an exception if there isn't enough data.
Raises:
EOFError: if the connection is closed without complete headers.
SecurityError: if the request exceeds a security limit.
ValueError: if the request isn't well formatted.
EOFError: If the connection is closed without complete headers.
SecurityError: If the request exceeds a security limit.
ValueError: If the request isn't well formatted.
"""
# https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2
Expand Down Expand Up @@ -350,8 +350,8 @@ def parse_line(
or raises an exception if there isn't enough data.
Raises:
EOFError: if the connection is closed without a CRLF.
SecurityError: if the response exceeds a security limit.
EOFError: If the connection is closed without a CRLF.
SecurityError: If the response exceeds a security limit.
"""
try:
Expand Down
10 changes: 5 additions & 5 deletions src/websockets/legacy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ async def read_http_request(self) -> Tuple[str, Headers]:
after this coroutine returns.
Raises:
InvalidMessage: if the HTTP message is malformed or isn't an
InvalidMessage: If the HTTP message is malformed or isn't an
HTTP/1.1 GET request.
"""
Expand Down Expand Up @@ -381,7 +381,7 @@ def process_origin(
origins: Optional list of acceptable origins.
Raises:
InvalidOrigin: if the origin isn't acceptable.
InvalidOrigin: If the origin isn't acceptable.
"""
# "The user agent MUST NOT include more than one Origin header field"
Expand Down Expand Up @@ -432,7 +432,7 @@ def process_extensions(
extensions: Optional list of supported extensions.
Raises:
InvalidHandshake: to abort the handshake with an HTTP 400 error.
InvalidHandshake: To abort the handshake with an HTTP 400 error.
"""
response_header_value: Optional[str] = None
Expand Down Expand Up @@ -492,7 +492,7 @@ def process_subprotocol(
available_subprotocols: Optional list of supported subprotocols.
Raises:
InvalidHandshake: to abort the handshake with an HTTP 400 error.
InvalidHandshake: To abort the handshake with an HTTP 400 error.
"""
subprotocol: Optional[Subprotocol] = None
Expand Down Expand Up @@ -574,7 +574,7 @@ async def handshake(
path of the URI of the request.
Raises:
InvalidHandshake: if the handshake fails.
InvalidHandshake: If the handshake fails.
"""
path, request_headers = await self.read_http_request()
Expand Down

0 comments on commit 2865bdc

Please sign in to comment.