From ed94da449cbb2dbf7ad141a1d394541893a7f847 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Sun, 25 Jan 2026 17:26:45 +0100 Subject: [PATCH] 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 --- gunicorn/http2/__init__.py | 2 +- gunicorn/http2/async_connection.py | 3 +-- gunicorn/http2/connection.py | 10 ++-------- gunicorn/http2/errors.py | 4 ---- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/gunicorn/http2/__init__.py b/gunicorn/http2/__init__.py index 6670fc68..e860677c 100644 --- a/gunicorn/http2/__init__.py +++ b/gunicorn/http2/__init__.py @@ -22,7 +22,7 @@ def is_http2_available(): Returns: 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: return _h2_available diff --git a/gunicorn/http2/async_connection.py b/gunicorn/http2/async_connection.py index 6c90c489..f4fe88b0 100644 --- a/gunicorn/http2/async_connection.py +++ b/gunicorn/http2/async_connection.py @@ -30,7 +30,7 @@ _h2_settings = None def _import_h2(): """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: return @@ -215,7 +215,6 @@ class AsyncHTTP2Connection: # Process headers stream.receive_headers(headers, end_stream=False) - return None def _handle_data_received(self, event): """Handle DataReceived event.""" diff --git a/gunicorn/http2/connection.py b/gunicorn/http2/connection.py index 41a7c2b9..4d99d09e 100644 --- a/gunicorn/http2/connection.py +++ b/gunicorn/http2/connection.py @@ -29,7 +29,7 @@ _h2_settings = None def _import_h2(): """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: return @@ -203,9 +203,6 @@ class HTTP2ServerConnection: Args: event: RequestReceived event with headers - - Returns: - HTTP2Request if stream ended with headers, None otherwise """ stream_id = event.stream_id headers = event.headers @@ -215,12 +212,9 @@ class HTTP2ServerConnection: self.streams[stream_id] = stream # Process headers + # The StreamEnded event will come separately for GET/HEAD with no body 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): """Handle DataReceived event. diff --git a/gunicorn/http2/errors.py b/gunicorn/http2/errors.py index b5b08fc9..b2dadf1b 100644 --- a/gunicorn/http2/errors.py +++ b/gunicorn/http2/errors.py @@ -114,14 +114,10 @@ class HTTP2StreamError(HTTP2Error): class HTTP2ConnectionError(HTTP2Error): """Error affecting the entire connection.""" - pass - class HTTP2ConfigurationError(HTTP2Error): """Invalid HTTP/2 configuration.""" - pass - class HTTP2NotAvailable(HTTP2Error): """HTTP/2 support is not available (h2 library not installed)."""