style: some of the suggestions from flake8
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 44cadf2..7e432c7 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -492,7 +492,9 @@
# Disconnected devices, at least on Linux, show the
# behavior that they are always ready to read immediately
# but reading returns nothing.
- raise SerialException('device reports readiness to read but returned no data (device disconnected or multiple access on port?)')
+ raise SerialException(
+ 'device reports readiness to read but returned no data '
+ '(device disconnected or multiple access on port?)')
read.extend(buf)
if timeout is not None:
timeout -= time.time() - start_time
diff --git a/serial/tools/hexlify_codec.py b/serial/tools/hexlify_codec.py
index fac85db..6d42080 100644
--- a/serial/tools/hexlify_codec.py
+++ b/serial/tools/hexlify_codec.py
@@ -15,8 +15,8 @@
HEXDIGITS = '0123456789ABCDEF'
-### Codec APIs
+# Codec APIs
def hex_encode(input, errors='strict'):
return (serial.to_bytes([int(h, 16) for h in input.split()]), len(input))
@@ -84,7 +84,8 @@
pass
-### encodings module API
+# encodings module API
+
def getregentry():
return codecs.CodecInfo(
name='hexlify',
diff --git a/serial/tools/list_ports_common.py b/serial/tools/list_ports_common.py
index 640b2a1..ae43d2d 100644
--- a/serial/tools/list_ports_common.py
+++ b/serial/tools/list_ports_common.py
@@ -56,8 +56,7 @@
self.vid,
self.pid,
' SER={}'.format(self.serial_number) if self.serial_number is not None else '',
- ' LOCATION={}'.format(self.location) if self.location is not None else '',
- )
+ ' LOCATION={}'.format(self.location) if self.location is not None else '')
def apply_usb_info(self):
"""update description and hwid from USB data"""
diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index 65a5031..b55c3bb 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -757,16 +757,14 @@
type=int,
metavar='NUM',
help="Unicode of special character that is used to exit the application, default: %(default)s",
- default=0x1d # GS/CTRL+]
- )
+ default=0x1d) # GS/CTRL+]
group.add_argument(
"--menu-char",
type=int,
metavar='NUM',
help="Unicode code of special character that is used to control miniterm (menu), default: %(default)s",
- default=0x14 # Menu: CTRL+T
- )
+ default=0x14) # Menu: CTRL+T
group = parser.add_argument_group("diagnostics")
@@ -859,8 +857,7 @@
key_description(miniterm.exit_character),
key_description(miniterm.menu_character),
key_description(miniterm.menu_character),
- key_description('\x08'),
- ))
+ key_description('\x08')))
miniterm.start()
try:
diff --git a/serial/urlhandler/protocol_loop.py b/serial/urlhandler/protocol_loop.py
index ab6c0b0..cce9f7d 100644
--- a/serial/urlhandler/protocol_loop.py
+++ b/serial/urlhandler/protocol_loop.py
@@ -90,7 +90,7 @@
protocol all settings are ignored!
"""
# not that's it of any real use, but it helps in the unit tests
- if not isinstance(self._baudrate, numbers.Integral) or not 0 < self._baudrate < 2**32:
+ if not isinstance(self._baudrate, numbers.Integral) or not 0 < self._baudrate < 2 ** 32:
raise ValueError("invalid baudrate: %r" % (self._baudrate))
if self.logger:
self.logger.info('_reconfigure_port()')
diff --git a/serial/urlhandler/protocol_spy.py b/serial/urlhandler/protocol_spy.py
index ba09e80..54bd55e 100644
--- a/serial/urlhandler/protocol_spy.py
+++ b/serial/urlhandler/protocol_spy.py
@@ -61,9 +61,7 @@
offset = 0
for h, a in sixteen(data):
if h is None:
- yield (offset, ' '.join([
- ''.join(values),
- ''.join(ascii)]))
+ yield (offset, ' '.join([''.join(values), ''.join(ascii)]))
del values[:]
del ascii[:]
offset += 0x10
@@ -162,7 +160,10 @@
"""extract host and port from an URL string"""
parts = urlparse.urlsplit(url)
if parts.scheme != 'spy':
- raise serial.SerialException('expected a string in the form "spy://port[?option[=value][&option[=value]]]": not starting with spy:// (%r)' % (parts.scheme,))
+ raise serial.SerialException(
+ 'expected a string in the form '
+ '"spy://port[?option[=value][&option[=value]]]": '
+ 'not starting with spy:// (%r)' % (parts.scheme,))
# process options now, directly altering self
formatter = FormatHexdump
color = False
@@ -180,7 +181,9 @@
else:
raise ValueError('unknown option: %r' % (option,))
except ValueError as e:
- raise serial.SerialException('expected a string in the form "spy://port[?option[=value][&option[=value]]]": %s' % e)
+ raise serial.SerialException(
+ 'expected a string in the form '
+ '"spy://port[?option[=value][&option[=value]]]": %s' % e)
self.formatter = formatter(output, color)
return ''.join([parts.netloc, parts.path])