From 69e71097f7a9633a43d566b2a46aab370f07dce3 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Thu, 18 Jun 2015 15:32:52 +0200 Subject: [PATCH] mark unused variables and arguments --- .landscape.yml | 3 +++ netlib/certutils.py | 2 +- netlib/http2/frame.py | 3 ++- netlib/http2/protocol.py | 15 +++++++-------- netlib/http_auth.py | 9 +++++---- netlib/http_cookies.py | 9 +++------ netlib/tcp.py | 10 +++++----- netlib/wsgi.py | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.landscape.yml b/.landscape.yml index 5926e7bf6..ccaa5fc36 100644 --- a/.landscape.yml +++ b/.landscape.yml @@ -1,5 +1,8 @@ max-line-length: 120 pylint: + options: + dummy-variables-rgx: _$|.+_$|dummy_.+ + disable: - missing-docstring - protected-access diff --git a/netlib/certutils.py b/netlib/certutils.py index ade61bb51..c6f0e6288 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -333,7 +333,7 @@ class CertStore(object): return entry.cert, entry.privatekey, entry.chain_file - def gen_pkey(self, cert): + def gen_pkey(self, cert_): # FIXME: We should do something with cert here? from . import certffi certffi.set_flags(self.default_privatekey, 1) diff --git a/netlib/http2/frame.py b/netlib/http2/frame.py index b4783a023..f7e604710 100644 --- a/netlib/http2/frame.py +++ b/netlib/http2/frame.py @@ -116,7 +116,8 @@ class Frame(object): self.length = len(self.payload_bytes()) return "\n".join([ - "%s: %s | length: %d | flags: %#x | stream_id: %d" % (direction, self.__class__.__name__, self.length, self.flags, self.stream_id), + "%s: %s | length: %d | flags: %#x | stream_id: %d" % ( + direction, self.__class__.__name__, self.length, self.flags, self.stream_id), self.payload_human_readable(), "===============================================================", ]) diff --git a/netlib/http2/protocol.py b/netlib/http2/protocol.py index ac89bac49..8e5f5429c 100644 --- a/netlib/http2/protocol.py +++ b/netlib/http2/protocol.py @@ -59,8 +59,8 @@ class HTTP2Protocol(object): while True: frm = self.read_frame(hide) if isinstance(frm, frame.SettingsFrame): - assert settings_ack_frame.flags & frame.Frame.FLAG_ACK - assert len(settings_ack_frame.settings) == 0 + assert frm.flags & frame.Frame.FLAG_ACK + assert len(frm.settings) == 0 break def perform_server_connection_preface(self, force=False): @@ -118,11 +118,10 @@ class HTTP2Protocol(object): old_value = '-' self.http2_settings[setting] = value - self.send_frame( - frame.SettingsFrame( - state=self, - flags=frame.Frame.FLAG_ACK), - hide) + frm = frame.SettingsFrame( + state=self, + flags=frame.Frame.FLAG_ACK) + self.send_frame(frm, hide) # be liberal in what we expect from the other end # to be more strict use: self._read_settings_ack(hide) @@ -188,7 +187,7 @@ class HTTP2Protocol(object): self._create_body(body, stream_id))) def read_response(self): - stream_id, headers, body = self._receive_transmission() + stream_id_, headers, body = self._receive_transmission() return headers[':status'], headers, body def read_request(self): diff --git a/netlib/http_auth.py b/netlib/http_auth.py index 0143760cd..adab4aed0 100644 --- a/netlib/http_auth.py +++ b/netlib/http_auth.py @@ -12,12 +12,13 @@ class NullProxyAuth(object): def __init__(self, password_manager): self.password_manager = password_manager - def clean(self, headers): + def clean(self, headers_): """ Clean up authentication headers, so they're not passed upstream. """ + pass - def authenticate(self, headers): + def authenticate(self, headers_): """ Tests that the user is allowed to use the proxy """ @@ -62,7 +63,7 @@ class BasicProxyAuth(NullProxyAuth): class PassMan(object): - def test(self, username, password_token): + def test(self, username_, password_token_): return False @@ -72,7 +73,7 @@ class PassManNonAnon(PassMan): Ensure the user specifies a username, accept any password. """ - def test(self, username, password_token): + def test(self, username, password_token_): if username: return True return False diff --git a/netlib/http_cookies.py b/netlib/http_cookies.py index b73117142..e91ee5c04 100644 --- a/netlib/http_cookies.py +++ b/netlib/http_cookies.py @@ -87,7 +87,7 @@ def _read_value(s, start, delims): return _read_until(s, start, delims) -def _read_pairs(s, off=0, specials=()): +def _read_pairs(s, off=0): """ Read pairs of lhs=rhs values. @@ -151,10 +151,7 @@ def _parse_set_cookie_pairs(s): For Set-Cookie, we support multiple cookies as described in RFC2109. This function therefore returns a list of lists. """ - pairs, off = _read_pairs( - s, - specials=("expires", "path") - ) + pairs, off_ = _read_pairs(s) return pairs @@ -185,7 +182,7 @@ def parse_cookie_header(line): Parse a Cookie header value. Returns a (possibly empty) ODict object. """ - pairs, off = _read_pairs(line) + pairs, off_ = _read_pairs(line) return odict.ODict(pairs) diff --git a/netlib/tcp.py b/netlib/tcp.py index 650757760..77eb7b52f 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -403,7 +403,7 @@ class _Connection(object): # Verify Options (NONE/PEER/PEER|FAIL_IF_... and trusted CAs) if verify_options is not None and verify_options is not SSL.VERIFY_NONE: - def verify_cert(conn, cert, errno, err_depth, is_cert_verified): + def verify_cert(conn_, cert_, errno, err_depth, is_cert_verified): if is_cert_verified: return True raise NetLibError( @@ -439,7 +439,7 @@ class _Connection(object): context.set_alpn_protos(alpn_protos) elif alpn_select is not None: # select application layer protocol - def alpn_select_callback(conn, options): + def alpn_select_callback(conn_, options): if alpn_select in options: return bytes(alpn_select) else: # pragma no cover @@ -601,7 +601,7 @@ class BaseHandler(_Connection): context.set_tlsext_servername_callback(handle_sni) if request_client_cert: - def save_cert(conn, cert, errno, depth, preverify_ok): + def save_cert(conn_, cert, errno_, depth_, preverify_ok_): self.clientcert = certutils.SSLCert(cert) # Return true to prevent cert verification error return True @@ -676,7 +676,7 @@ class TCPServer(object): try: while not self.__shutdown_request: try: - r, w, e = select.select( + r, w_, e_ = select.select( [self.socket], [], [], poll_interval) except select.error as ex: # pragma: no cover if ex[0] == EINTR: @@ -708,7 +708,7 @@ class TCPServer(object): self.socket.close() self.handle_shutdown() - def handle_error(self, connection, client_address, fp=sys.stderr): + def handle_error(self, connection_, client_address, fp=sys.stderr): """ Called when handle_client_connection raises an exception. """ diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 827cf6f0b..ad43dc198 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -35,7 +35,7 @@ def date_time_string(): 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] now = time.time() - year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now) + year, month, day, hh, mm, ss, wd, y_, z_ = time.gmtime(now) s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( WEEKS[wd], day, MONTHS[month], year,