From a08087249fda8a7994f7c54ccaad29fb9fcc448a Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 2 Feb 2023 15:09:36 +1100 Subject: [PATCH] top: Update Python formatting to black "2023 stable style". See https://black.readthedocs.io/en/stable/the_black_code_style/index.html Signed-off-by: Jim Mussared --- micropython/bluetooth/aioble/aioble/client.py | 1 + .../bluetooth/aioble/multitests/ble_write_order.py | 1 + micropython/drivers/codec/wm8960/wm8960.py | 12 ------------ micropython/drivers/display/ssd1306/ssd1306.py | 1 + micropython/drivers/storage/sdcard/sdcard.py | 1 - micropython/umqtt.robust/umqtt/robust.py | 1 - micropython/umqtt.simple/example_sub.py | 1 + python-stdlib/contextlib/tests.py | 1 - python-stdlib/copy/copy.py | 1 + python-stdlib/json/json/encoder.py | 1 - python-stdlib/logging/examples/example_logging_2.py | 1 + python-stdlib/textwrap/textwrap.py | 1 - python-stdlib/unittest/tests/test_assertions.py | 1 - unix-ffi/email.internal/email/_encoded_words.py | 1 - unix-ffi/email.internal/email/_policybase.py | 1 - unix-ffi/email.utils/email/utils.py | 1 + unix-ffi/html.entities/html/entities.py | 2 +- unix-ffi/http.client/http/client.py | 1 - unix-ffi/machine/machine/pin.py | 1 - unix-ffi/urllib.parse/urllib/parse.py | 1 + 20 files changed, 9 insertions(+), 23 deletions(-) diff --git a/micropython/bluetooth/aioble/aioble/client.py b/micropython/bluetooth/aioble/aioble/client.py index 8f3bf2c..a205e0a 100644 --- a/micropython/bluetooth/aioble/aioble/client.py +++ b/micropython/bluetooth/aioble/aioble/client.py @@ -34,6 +34,7 @@ _FLAG_WRITE = const(0x0008) _FLAG_NOTIFY = const(0x0010) _FLAG_INDICATE = const(0x0020) + # Forward IRQs directly to static methods on the type that handles them and # knows how to map handles to instances. Note: We copy all uuid and data # params here for safety, but a future optimisation might be able to avoid diff --git a/micropython/bluetooth/aioble/multitests/ble_write_order.py b/micropython/bluetooth/aioble/multitests/ble_write_order.py index 4b64031..8bd15e4 100644 --- a/micropython/bluetooth/aioble/multitests/ble_write_order.py +++ b/micropython/bluetooth/aioble/multitests/ble_write_order.py @@ -21,6 +21,7 @@ SERVICE_UUID = bluetooth.UUID("A5A5A5A5-FFFF-9999-1111-5A5A5A5A5A5A") CHAR_FIRST_UUID = bluetooth.UUID("00000000-1111-2222-3333-444444444444") CHAR_SECOND_UUID = bluetooth.UUID("00000000-1111-2222-3333-555555555555") + # Acting in peripheral role. async def instance0_task(): service = aioble.Service(SERVICE_UUID) diff --git a/micropython/drivers/codec/wm8960/wm8960.py b/micropython/drivers/codec/wm8960/wm8960.py index ad1cb1c..d167022 100644 --- a/micropython/drivers/codec/wm8960/wm8960.py +++ b/micropython/drivers/codec/wm8960/wm8960.py @@ -244,7 +244,6 @@ class Regs: class WM8960: - _bit_clock_divider_table = { 2: 0, 3: 1, @@ -399,7 +398,6 @@ class WM8960: self.config_data_format(sysclk, sample_rate, bits) def deinit(self): - self.set_module(MODULE_ADC, False) self.set_module(MODULE_DAC, False) self.set_module(MODULE_VREF, False) @@ -467,33 +465,28 @@ class WM8960: ) def set_module(self, module, is_enabled): - is_enabled = 1 if is_enabled else 0 regs = self.regs if module == MODULE_ADC: - regs[_POWER1] = ( _POWER1_ADCL_MASK | _POWER1_ADCR_MASK, (_POWER1_ADCL_MASK | _POWER1_ADCR_MASK) * is_enabled, ) elif module == MODULE_DAC: - regs[_POWER2] = ( _POWER2_DACL_MASK | _POWER2_DACR_MASK, (_POWER2_DACL_MASK | _POWER2_DACR_MASK) * is_enabled, ) elif module == MODULE_VREF: - regs[_POWER1] = ( _POWER1_VREF_MASK, (is_enabled << _POWER1_VREF_SHIFT), ) elif module == MODULE_LINE_IN: - regs[_POWER1] = ( _POWER1_AINL_MASK | _POWER1_AINR_MASK, (_POWER1_AINL_MASK | _POWER1_AINR_MASK) * is_enabled, @@ -504,21 +497,18 @@ class WM8960: ) elif module == MODULE_LINE_OUT: - regs[_POWER2] = ( _POWER2_LOUT1_MASK | _POWER2_ROUT1_MASK, (_POWER2_LOUT1_MASK | _POWER2_ROUT1_MASK) * is_enabled, ) elif module == MODULE_MIC_BIAS: - regs[_POWER1] = ( _POWER1_MICB_MASK, (is_enabled << _POWER1_MICB_SHIFT), ) elif module == MODULE_SPEAKER: - regs[_POWER2] = ( _POWER2_SPKL_MASK | _POWER2_SPKR_MASK, (_POWER2_SPKL_MASK | _POWER2_SPKR_MASK) * is_enabled, @@ -526,14 +516,12 @@ class WM8960: regs[_CLASSD1] = 0xF7 elif module == MODULE_OMIX: - regs[_POWER3] = ( _POWER3_LOMIX_MASK | _POWER3_ROMIX_MASK, (_POWER3_LOMIX_MASK | _POWER3_ROMIX_MASK) * is_enabled, ) elif module == MODULE_MONO_OUT: - regs[_MONOMIX1] = regs[_MONOMIX2] = is_enabled << 7 regs[_MONO] = is_enabled << 6 diff --git a/micropython/drivers/display/ssd1306/ssd1306.py b/micropython/drivers/display/ssd1306/ssd1306.py index a504cda..37ad682 100644 --- a/micropython/drivers/display/ssd1306/ssd1306.py +++ b/micropython/drivers/display/ssd1306/ssd1306.py @@ -24,6 +24,7 @@ SET_PRECHARGE = const(0xD9) SET_VCOM_DESEL = const(0xDB) SET_CHARGE_PUMP = const(0x8D) + # Subclassing FrameBuffer provides support for graphics primitives # http://docs.micropython.org/en/latest/pyboard/library/framebuf.html class SSD1306(framebuf.FrameBuffer): diff --git a/micropython/drivers/storage/sdcard/sdcard.py b/micropython/drivers/storage/sdcard/sdcard.py index 0c9f2d5..c9c991f 100644 --- a/micropython/drivers/storage/sdcard/sdcard.py +++ b/micropython/drivers/storage/sdcard/sdcard.py @@ -64,7 +64,6 @@ class SDCard: self.spi.init(master, baudrate=baudrate, phase=0, polarity=0) def init_card(self, baudrate): - # init CS pin self.cs.init(self.cs.OUT, value=1) diff --git a/micropython/umqtt.robust/umqtt/robust.py b/micropython/umqtt.robust/umqtt/robust.py index d9e4e9e..4cc10e3 100644 --- a/micropython/umqtt.robust/umqtt/robust.py +++ b/micropython/umqtt.robust/umqtt/robust.py @@ -3,7 +3,6 @@ from . import simple class MQTTClient(simple.MQTTClient): - DELAY = 2 DEBUG = False diff --git a/micropython/umqtt.simple/example_sub.py b/micropython/umqtt.simple/example_sub.py index 890aa29..41fc55b 100644 --- a/micropython/umqtt.simple/example_sub.py +++ b/micropython/umqtt.simple/example_sub.py @@ -4,6 +4,7 @@ from umqtt.simple import MQTTClient # Publish test messages e.g. with: # mosquitto_pub -t foo_topic -m hello + # Received messages from subscriptions will be delivered to this callback def sub_cb(topic, msg): print((topic, msg)) diff --git a/python-stdlib/contextlib/tests.py b/python-stdlib/contextlib/tests.py index fd924cf..19f07ad 100644 --- a/python-stdlib/contextlib/tests.py +++ b/python-stdlib/contextlib/tests.py @@ -37,7 +37,6 @@ class SuppressTestCase(unittest.TestCase): class TestExitStack(unittest.TestCase): - # @support.requires_docstrings def _test_instance_docs(self): # Issue 19330: ensure context manager instances have good docstrings diff --git a/python-stdlib/copy/copy.py b/python-stdlib/copy/copy.py index 024a428..f7bfdd6 100644 --- a/python-stdlib/copy/copy.py +++ b/python-stdlib/copy/copy.py @@ -374,6 +374,7 @@ del d del types + # Helper for instance creation without calling __init__ class _EmptyClass: pass diff --git a/python-stdlib/json/json/encoder.py b/python-stdlib/json/json/encoder.py index ba798a0..2adf366 100644 --- a/python-stdlib/json/json/encoder.py +++ b/python-stdlib/json/json/encoder.py @@ -294,7 +294,6 @@ def _make_iterencode( str=str, tuple=tuple, ): - if _indent is not None and not isinstance(_indent, str): _indent = " " * _indent diff --git a/python-stdlib/logging/examples/example_logging_2.py b/python-stdlib/logging/examples/example_logging_2.py index a349d13..1dba328 100644 --- a/python-stdlib/logging/examples/example_logging_2.py +++ b/python-stdlib/logging/examples/example_logging_2.py @@ -37,6 +37,7 @@ try: except: logger.error("Some trouble (%s)", "expected") + # Custom handler example class MyHandler(logging.Handler): def emit(self, record): diff --git a/python-stdlib/textwrap/textwrap.py b/python-stdlib/textwrap/textwrap.py index 4243871..4e9f350 100644 --- a/python-stdlib/textwrap/textwrap.py +++ b/python-stdlib/textwrap/textwrap.py @@ -248,7 +248,6 @@ class TextWrapper: chunks.reverse() while chunks: - # Start the list of chunks that will make up the current line. # cur_len is just the length of all the chunks in cur_line. cur_line = [] diff --git a/python-stdlib/unittest/tests/test_assertions.py b/python-stdlib/unittest/tests/test_assertions.py index 089a528..b191220 100644 --- a/python-stdlib/unittest/tests/test_assertions.py +++ b/python-stdlib/unittest/tests/test_assertions.py @@ -112,7 +112,6 @@ class TestUnittestAssertions(unittest.TestCase): self.fail("this should be skipped") def testAssert(self): - e1 = None try: diff --git a/unix-ffi/email.internal/email/_encoded_words.py b/unix-ffi/email.internal/email/_encoded_words.py index ac982cf..683ff3c 100644 --- a/unix-ffi/email.internal/email/_encoded_words.py +++ b/unix-ffi/email.internal/email/_encoded_words.py @@ -74,7 +74,6 @@ def decode_q(encoded): # dict mapping bytes to their encoded form class _QByteMap(dict): - safe = b"-!*+/" + ascii_letters.encode("ascii") + digits.encode("ascii") def __missing__(self, key): diff --git a/unix-ffi/email.internal/email/_policybase.py b/unix-ffi/email.internal/email/_policybase.py index f594342..7e93ca4 100644 --- a/unix-ffi/email.internal/email/_policybase.py +++ b/unix-ffi/email.internal/email/_policybase.py @@ -115,7 +115,6 @@ def _extend_docstrings(cls): class Policy(_PolicyBase): # , metaclass=abc.ABCMeta): - r"""Controls for how messages are interpreted and formatted. Most of the classes and many of the methods in the email package accept diff --git a/unix-ffi/email.utils/email/utils.py b/unix-ffi/email.utils/email/utils.py index e0ebdd3..b67502c 100644 --- a/unix-ffi/email.utils/email/utils.py +++ b/unix-ffi/email.utils/email/utils.py @@ -58,6 +58,7 @@ escapesre = re.compile(r'[\\"]') # source with undecodable characters. _has_surrogates = re.compile("([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)").search + # How to deal with a string containing bytes before handing it to the # application through the 'normal' interface. def _sanitize(string): diff --git a/unix-ffi/html.entities/html/entities.py b/unix-ffi/html.entities/html/entities.py index b4644b3..223af74 100644 --- a/unix-ffi/html.entities/html/entities.py +++ b/unix-ffi/html.entities/html/entities.py @@ -2499,7 +2499,7 @@ codepoint2name = {} # (or a character reference if the character is outside the Latin-1 range) entitydefs = {} -for (name, codepoint) in name2codepoint.items(): +for name, codepoint in name2codepoint.items(): codepoint2name[codepoint] = name entitydefs[name] = chr(codepoint) diff --git a/unix-ffi/http.client/http/client.py b/unix-ffi/http.client/http/client.py index 5d30cbf..8568482 100644 --- a/unix-ffi/http.client/http/client.py +++ b/unix-ffi/http.client/http/client.py @@ -740,7 +740,6 @@ class HTTPResponse: class HTTPConnection: - _http_vsn = 11 _http_vsn_str = "HTTP/1.1" diff --git a/unix-ffi/machine/machine/pin.py b/unix-ffi/machine/machine/pin.py index 9774bf1..c7d827b 100644 --- a/unix-ffi/machine/machine/pin.py +++ b/unix-ffi/machine/machine/pin.py @@ -2,7 +2,6 @@ import umachine class Pin(umachine.PinBase): - IN = "in" OUT = "out" diff --git a/unix-ffi/urllib.parse/urllib/parse.py b/unix-ffi/urllib.parse/urllib/parse.py index 709cc57..1ec7537 100644 --- a/unix-ffi/urllib.parse/urllib/parse.py +++ b/unix-ffi/urllib.parse/urllib/parse.py @@ -332,6 +332,7 @@ _ParseResultBase = namedtuple("ParseResult", "scheme netloc path params query fr # retained since deprecating it isn't worth the hassle ResultBase = _NetlocResultMixinStr + # Structured result objects for string data class DefragResult(_DefragResultBase, _ResultMixinStr): __slots__ = ()