Skip to content

Commit 406ceb1

Browse files
author
brentru
committed
linty linty
1 parent 40cc29d commit 406ceb1

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def set_dhcp(self, response_timeout=1):
208208
_dhcp_client.gateway_ip[2], _dhcp_client.gateway_ip[3])
209209

210210
self._dns = (_dhcp_client.dns_server_ip[0], _dhcp_client.dns_server_ip[1],
211-
_dhcp_client.dns_server_ip[2], _dhcp_client.dns_server_ip[3])
211+
_dhcp_client.dns_server_ip[2], _dhcp_client.dns_server_ip[3])
212212
self.ifconfig = ((_ip, _subnet_mask, _gw_addr, self._dns))
213213
return 0
214214
self._src_port = 0

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def __init__(self, eth, mac_address, timeout=1, timeout_response=1):
120120
def send_dhcp_message(self, state, time_elapsed):
121121
"""Assemble and send a DHCP message packet to a socket.
122122
:param int state: DHCP Message state.
123-
:param float time_elapsed: Number of seconds elapsed since client attempted to acquire/renew a lease.
123+
:param float time_elapsed: Number of seconds elapsed since
124+
client attempted to acquire/renew a lease.
124125
125126
"""
126127
# OP

adafruit_wiznet5k/adafruit_wiznet5k_dns.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
3737
from adafruit_wiznet5k.adafruit_wiznet5k_socket import htons
3838

39+
# pylint: disable=bad-whitespace
40+
3941
QUERY_FLAG = const(0x00)
4042
OPCODE_STANDARD_QUERY = const(0x00)
4143
RECURSION_DESIRED_FLAG = 1<<8
@@ -51,7 +53,8 @@
5153
TRUNCATED = const(-3)
5254
INVALID_RESPONSE = const(-4)
5355

54-
DNS_PORT = const(0x35) # port used for DNS request
56+
DNS_PORT = const(0x35) # port used for DNS request
57+
# pylint: enable=bad-whitespace
5558

5659
class DNS:
5760
"""W5K DNS implementation.
@@ -91,8 +94,8 @@ def gethostbyname(self, hostname):
9194
addr = -1
9295
while (retries < 3) and (addr == -1):
9396
addr = self._parse_dns_response()
94-
retries+=1
95-
97+
retries += 1
98+
9699
self._sock.close()
97100
return addr
98101

@@ -116,7 +119,6 @@ def _parse_dns_response(self):
116119
# Validate request identifier
117120
if not hex(int.from_bytes(self._pkt_buf[0:2], 'l')) == hex(self._request_id):
118121
return -1
119-
120122
# Validate flags
121123
if not int.from_bytes(self._pkt_buf[2:4], 'l') == 0x8180:
122124
return -1
@@ -136,11 +138,8 @@ def _parse_dns_response(self):
136138
return -1
137139
# return the address
138140
return self._pkt_buf[51:55]
139-
else:
140-
# not the correct answer type or class
141-
an_count+=1
142-
143-
return -1
141+
# not the correct answer type or class
142+
an_count += 1
144143

145144
def _build_dns_header(self):
146145
"""Builds DNS header."""
@@ -186,5 +185,3 @@ def _build_dns_question(self):
186185
# Class IN
187186
self._pkt_buf.append(htons(CLASS_IN) & 0xFF)
188187
self._pkt_buf.append(htons(CLASS_IN) >> 8)
189-
190-

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def htons(x):
6060
# keep track of sockets we allocate
6161
SOCKETS = []
6262

63+
#pylint: disable=too-many-arguments, unused-argument
6364
def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0):
6465
"""Translate the host/port argument into a sequence of 5-tuples that
6566
contain all the necessary arguments for creating a socket connected to that service.
@@ -74,9 +75,9 @@ def gethostbyname(hostname):
7475
is returned as a string.
7576
:param str hostname: Desired hostname.
7677
"""
77-
ip = _the_interface.get_host_by_name(hostname)
78-
ip = "{}.{}.{}.{}".format(ip[0], ip[1], ip[2], ip[3])
79-
return ip
78+
addr = _the_interface.get_host_by_name(hostname)
79+
addr = "{}.{}.{}.{}".format(addr[0], addr[1], addr[2], addr[3])
80+
return addr
8081

8182
#pylint: disable=invalid-name
8283
class socket:
@@ -86,12 +87,12 @@ class socket:
8687
:param int type: Socket type.
8788
8889
"""
89-
# pylint: disable=redefined-builtin
90+
# pylint: disable=redefined-builtin,unused-argument
9091
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, socknum=None):
9192
if family != AF_INET:
9293
raise RuntimeError("Only AF_INET family supported by W5K modules.")
9394
self._sock_type = type
94-
self._buffer = b''
95+
self._buffer = b""
9596
self._timeout = 0
9697

9798
self._socknum = _the_interface.get_socket(SOCKETS)
@@ -129,10 +130,10 @@ def inet_aton(self, ip_string):
129130
:param str ip_string: IP Address, as a dotted-quad string.
130131
131132
"""
132-
self._bufffer = b""
133-
self._bufffer = [int(item) for item in ip_string.split('.')]
134-
self._bufffer = bytearray(self._bufffer)
135-
return self._bufffer
133+
self._buffer = b''
134+
self._buffer = [int(item) for item in ip_string.split('.')]
135+
self._buffer = bytearray(self._buffer)
136+
return self._buffer
136137

137138
def connect(self, address, conntype=None):
138139
"""Connect to a remote socket at address. (The format of address depends

0 commit comments

Comments
 (0)