mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-02 18:51:31 +08:00
Fix pylint issues in HTTP/2 module
- Add pylint disable comments for global-statement in lazy import pattern - Remove unnecessary pass statements in error subclasses - Remove useless return None at end of _handle_request_received methods
This commit is contained in:
parent
9306db1d20
commit
ed94da449c
@ -22,7 +22,7 @@ def is_http2_available():
|
|||||||
Returns:
|
Returns:
|
||||||
bool: True if the h2 library is installed with minimum required version.
|
bool: True if the h2 library is installed with minimum required version.
|
||||||
"""
|
"""
|
||||||
global _h2_available, _h2_version
|
global _h2_available, _h2_version # pylint: disable=global-statement
|
||||||
|
|
||||||
if _h2_available is not None:
|
if _h2_available is not None:
|
||||||
return _h2_available
|
return _h2_available
|
||||||
|
|||||||
@ -30,7 +30,7 @@ _h2_settings = None
|
|||||||
|
|
||||||
def _import_h2():
|
def _import_h2():
|
||||||
"""Lazily import h2 library components."""
|
"""Lazily import h2 library components."""
|
||||||
global _h2, _h2_config, _h2_events, _h2_exceptions, _h2_settings
|
global _h2, _h2_config, _h2_events, _h2_exceptions, _h2_settings # pylint: disable=global-statement
|
||||||
|
|
||||||
if _h2 is not None:
|
if _h2 is not None:
|
||||||
return
|
return
|
||||||
@ -215,7 +215,6 @@ class AsyncHTTP2Connection:
|
|||||||
|
|
||||||
# Process headers
|
# Process headers
|
||||||
stream.receive_headers(headers, end_stream=False)
|
stream.receive_headers(headers, end_stream=False)
|
||||||
return None
|
|
||||||
|
|
||||||
def _handle_data_received(self, event):
|
def _handle_data_received(self, event):
|
||||||
"""Handle DataReceived event."""
|
"""Handle DataReceived event."""
|
||||||
|
|||||||
@ -29,7 +29,7 @@ _h2_settings = None
|
|||||||
|
|
||||||
def _import_h2():
|
def _import_h2():
|
||||||
"""Lazily import h2 library components."""
|
"""Lazily import h2 library components."""
|
||||||
global _h2, _h2_config, _h2_events, _h2_exceptions, _h2_settings
|
global _h2, _h2_config, _h2_events, _h2_exceptions, _h2_settings # pylint: disable=global-statement
|
||||||
|
|
||||||
if _h2 is not None:
|
if _h2 is not None:
|
||||||
return
|
return
|
||||||
@ -203,9 +203,6 @@ class HTTP2ServerConnection:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
event: RequestReceived event with headers
|
event: RequestReceived event with headers
|
||||||
|
|
||||||
Returns:
|
|
||||||
HTTP2Request if stream ended with headers, None otherwise
|
|
||||||
"""
|
"""
|
||||||
stream_id = event.stream_id
|
stream_id = event.stream_id
|
||||||
headers = event.headers
|
headers = event.headers
|
||||||
@ -215,12 +212,9 @@ class HTTP2ServerConnection:
|
|||||||
self.streams[stream_id] = stream
|
self.streams[stream_id] = stream
|
||||||
|
|
||||||
# Process headers
|
# Process headers
|
||||||
|
# The StreamEnded event will come separately for GET/HEAD with no body
|
||||||
stream.receive_headers(headers, end_stream=False)
|
stream.receive_headers(headers, end_stream=False)
|
||||||
|
|
||||||
# Check if this was a GET/HEAD with no body
|
|
||||||
# The StreamEnded event will come separately
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _handle_data_received(self, event):
|
def _handle_data_received(self, event):
|
||||||
"""Handle DataReceived event.
|
"""Handle DataReceived event.
|
||||||
|
|
||||||
|
|||||||
@ -114,14 +114,10 @@ class HTTP2StreamError(HTTP2Error):
|
|||||||
class HTTP2ConnectionError(HTTP2Error):
|
class HTTP2ConnectionError(HTTP2Error):
|
||||||
"""Error affecting the entire connection."""
|
"""Error affecting the entire connection."""
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class HTTP2ConfigurationError(HTTP2Error):
|
class HTTP2ConfigurationError(HTTP2Error):
|
||||||
"""Invalid HTTP/2 configuration."""
|
"""Invalid HTTP/2 configuration."""
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class HTTP2NotAvailable(HTTP2Error):
|
class HTTP2NotAvailable(HTTP2Error):
|
||||||
"""HTTP/2 support is not available (h2 library not installed)."""
|
"""HTTP/2 support is not available (h2 library not installed)."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user