From 28a1afca63104c09db53ef2fbc03cd416d425698 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 Dec 2023 11:54:36 +0100 Subject: [PATCH] python: reformat with black-23.7.0-2.fc39.noarch The base image for the "check-tree" test got bumped to Fedora 39. This brings a new python-black version (23.7.0 vs. 22.8.0) and requires reformatting. Maybe we should stick to 22.8.0, via `pip install`. But it seems better to just follow the latest black version (the one from current Fedora). So do the reformatting instead. https://black.readthedocs.io/en/stable/change_log.html#id38 --- examples/python/gi/gmaincontext.py | 4 +--- examples/python/gi/nm-add-connection2.py | 1 - examples/python/gi/nm-up-many.py | 10 ---------- examples/python/gi/nm-update2.py | 1 - examples/python/gi/nm-wg-set | 2 -- examples/python/gi/ovs-external-ids.py | 9 --------- src/libnm-client-impl/tests/test-gir.py | 2 +- tools/generate-docs-nm-property-infos.py | 4 ---- tools/generate-docs-nm-settings-docs-merge.py | 2 -- tools/test-cloud-meta-mock.py | 2 -- tools/test-networkmanager-service.py | 15 --------------- 11 files changed, 2 insertions(+), 50 deletions(-) diff --git a/examples/python/gi/gmaincontext.py b/examples/python/gi/gmaincontext.py index 64a5620b6..25283f180 100755 --- a/examples/python/gi/gmaincontext.py +++ b/examples/python/gi/gmaincontext.py @@ -71,6 +71,7 @@ def error_is_cancelled(e): ############################################################################### + # A Context manager for running a mainloop. Of course, this does # not do anything magically. You can run the context/mainloop without # this context object. @@ -265,7 +266,6 @@ def create_nmc(dbus_connection): def make_call(nmc): - log("[make_call]: make some async D-Bus call") if not nmc: @@ -273,7 +273,6 @@ def make_call(nmc): return with MainLoopRun("make_call", nmc.get_main_context(), 1) as r: - # There are two reasons why async operations are preferable with # D-Bus and libnm: # @@ -405,7 +404,6 @@ def destroy_nmc(nmc_holder, destroy_mode): raise Exception("Failure to destroy NMClient: something keeps it alive") else: - if destroy_mode == 1: ctx = GLib.MainContext.default() else: diff --git a/examples/python/gi/nm-add-connection2.py b/examples/python/gi/nm-add-connection2.py index 2cd760a20..7ac95c6dc 100755 --- a/examples/python/gi/nm-add-connection2.py +++ b/examples/python/gi/nm-add-connection2.py @@ -49,7 +49,6 @@ def die(msg, print_usage=False): def main(): - main_loop = GLib.MainLoop() nm_client = NM.Client.new(None) diff --git a/examples/python/gi/nm-up-many.py b/examples/python/gi/nm-up-many.py index e5faad194..3bca3e5ae 100755 --- a/examples/python/gi/nm-up-many.py +++ b/examples/python/gi/nm-up-many.py @@ -51,7 +51,6 @@ def nmc_new(io_priority=GLib.PRIORITY_DEFAULT, cancellable=None): result = [] def cb(source_object, res): - try: source_object.init_finish(res) except Exception as e: @@ -73,7 +72,6 @@ def nmc_new(io_priority=GLib.PRIORITY_DEFAULT, cancellable=None): def nmc_destroy(nmc_transfer_ref): - # Just for fun, show how to completely cleanup a NMClient instance. # An NMClient instance registers D-Bus signals and unrefing the instance # will cancel/unsubscribe those signals, but there might still be some @@ -106,7 +104,6 @@ def nmc_destroy(nmc_transfer_ref): def find_connections(nmc, argv): - # parse the inpurt argv and select the connection profiles to activate. # The arguments are either "connection.id" or "connection.uuid", possibly # qualified by "id" or "uuid". @@ -173,7 +170,6 @@ class Activation(object): return "%s (%s)" % (self.con.get_id(), self.con.get_uuid()) def is_done(self, log=log): - if self.state == Activation.ACTIVATION_STATE_DONE: return True @@ -206,7 +202,6 @@ class Activation(object): return False def start(self, nmc, cancellable=None, activated_callback=None, log=log): - # Call nmc.activate_connection_async() and return a user data # with the information about the pending operation. @@ -242,7 +237,6 @@ class Activation(object): ) def wait(self, done_callback=None, log=log): - assert self.state == Activation.ACTIVATION_STATE_WAITING assert self.result_ac assert self.wait_id is None @@ -259,7 +253,6 @@ class Activation(object): class Manager(object): def __init__(self, nmc, cons): - self.nmc = nmc self.ac_start = [Activation(c) for c in cons] @@ -268,7 +261,6 @@ class Manager(object): self.ac_done = [] def _log(self, msg): - lists = [self.ac_start, self.ac_starting, self.ac_waiting, self.ac_done] n = sum(len(l) for l in lists) @@ -278,11 +270,9 @@ class Manager(object): log("%s: %s" % (prefix, msg)) def ac_run(self): - loop = GLib.MainLoop(self.nmc.get_main_context()) while self.ac_start or self.ac_starting or self.ac_waiting: - rate_limit_parallel_in_progress = ( len(self.ac_starting) + len(self.ac_waiting) >= NUM_PARALLEL_IN_PROGRESS ) diff --git a/examples/python/gi/nm-update2.py b/examples/python/gi/nm-update2.py index 9d272ead8..87dd6fb12 100755 --- a/examples/python/gi/nm-update2.py +++ b/examples/python/gi/nm-update2.py @@ -52,7 +52,6 @@ def die(msg, print_usage=False): def main(): - main_loop = GLib.MainLoop() nm_client = NM.Client.new(None) diff --git a/examples/python/gi/nm-wg-set b/examples/python/gi/nm-wg-set index 4d1625702..dd7e81f75 100755 --- a/examples/python/gi/nm-wg-set +++ b/examples/python/gi/nm-wg-set @@ -146,7 +146,6 @@ def print_hint(nm_client): def argv_get_one(argv, idx, type_ctor=None, topic=None): - if topic is not None: try: v = argv_get_one(argv, idx, type_ctor, None) @@ -479,7 +478,6 @@ def do_set(nm_client, conn, argv): ############################################################################### if __name__ == "__main__": - nm_client = NM.Client.new(None) argv = sys.argv diff --git a/examples/python/gi/ovs-external-ids.py b/examples/python/gi/ovs-external-ids.py index 0a03c9c56..b33b4581f 100755 --- a/examples/python/gi/ovs-external-ids.py +++ b/examples/python/gi/ovs-external-ids.py @@ -111,7 +111,6 @@ def mainloop_run(timeout_msec=0, mainloop=None): def connection_update2(remote_connection, connection): - mainloop = GLib.MainLoop() result_error = [] @@ -160,7 +159,6 @@ def device_get_applied_connection(device): def device_reapply(device, connection, version_id): - mainloop = GLib.MainLoop() result_error = [] @@ -443,7 +441,6 @@ def connection_print(connection, mode, ids_arg, dbus_path, prefix=""): _print("%s %s" % (prefix, dbus_path)) for data_type in [DataTypeE, DataTypeO]: - if data_type.setting_type is None: continue @@ -465,7 +462,6 @@ def connection_print(connection, mode, ids_arg, dbus_path, prefix=""): def sett_update(connection, ids_arg): - for d in ids_arg: op = d[0][0] key = d[0][1:] @@ -554,7 +550,6 @@ def do_get(connections, ids_arg): def do_set(nmc, connection, ids_arg, do_test): - remote_connection = connection connection = NM.SimpleConnection.new_clone(remote_connection) @@ -611,7 +606,6 @@ def do_set(nmc, connection, ids_arg, do_test): def do_apply(nmc, device, ids_arg, do_test): - try: connection_orig, version_id = device_get_applied_connection(device) except Exception as e: @@ -677,13 +671,11 @@ def do_apply(nmc, device, ids_arg, do_test): ############################################################################### if __name__ == "__main__": - args = parse_args(sys.argv) nmc = NM.Client.new(None) if args["mode"] == MODE_APPLY: - devices = devices_filter(nmc.get_devices(), args["select_arg"]) if len(devices) != 1: @@ -695,7 +687,6 @@ if __name__ == "__main__": do_apply(nmc, devices[0], args["ids_arg"], do_test=args["do_test"]) else: - connections = connections_filter(nmc.get_connections(), args["select_arg"]) if args["mode"] == MODE_SET: diff --git a/src/libnm-client-impl/tests/test-gir.py b/src/libnm-client-impl/tests/test-gir.py index 9b42431c1..554080fa8 100755 --- a/src/libnm-client-impl/tests/test-gir.py +++ b/src/libnm-client-impl/tests/test-gir.py @@ -118,7 +118,7 @@ ver_syms = syms_from_ver(args.ver) exit_code = 0 -for (gir_sym, gir_ver) in gir_syms.items(): +for gir_sym, gir_ver in gir_syms.items(): if gir_sym not in ver_syms: exit_code = 1 print( diff --git a/tools/generate-docs-nm-property-infos.py b/tools/generate-docs-nm-property-infos.py index 4d91a7eb1..74dc9d1c4 100755 --- a/tools/generate-docs-nm-property-infos.py +++ b/tools/generate-docs-nm-property-infos.py @@ -184,7 +184,6 @@ def keywords_allowed(tag, keyword): def write_data(tag, setting_node, line_no, parsed_data): - for k in parsed_data.keys(): assert keywords_allowed(tag, k) assert k in keywords @@ -375,7 +374,6 @@ def parse_data(tag, line_no, lines): def process_setting(tag, root_node, source_file, setting_name): - dbg( "> > tag:%s, source_file:%s, setting_name:%s" % (tag, source_file, setting_name) ) @@ -448,7 +446,6 @@ def process_setting(tag, root_node, source_file, setting_name): def process_settings_docs(tag, output, gir_file, source_files): - dbg("> tag:%s, output:%s" % (tag, output)) root_node = ET.Element("nm-setting-docs") @@ -531,7 +528,6 @@ def test_get_setting_names(): def test_get_file_infos(): - t = ["connection", "ip-config", "ip4-config", "proxy", "wired"] assert [ diff --git a/tools/generate-docs-nm-settings-docs-merge.py b/tools/generate-docs-nm-settings-docs-merge.py index 5d4e00a1e..3ad8755dc 100755 --- a/tools/generate-docs-nm-settings-docs-merge.py +++ b/tools/generate-docs-nm-settings-docs-merge.py @@ -250,7 +250,6 @@ settings_roots = [node_to_dict(root, "setting", "name") for root in xml_roots] root_node = ET.Element("nm-setting-docs") for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name): - dbg("> > setting_name: %s" % (setting_name)) if skip_property(setting_name, None): @@ -272,7 +271,6 @@ for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name): dbg("> > > create node") for property_name in iter_keys_of_dicts(properties): - dbg("> > > > property_name: %s" % (property_name)) properties_attrs = [p.get(property_name) for p in properties] diff --git a/tools/test-cloud-meta-mock.py b/tools/test-cloud-meta-mock.py index bc0a829ec..a396e0da4 100755 --- a/tools/test-cloud-meta-mock.py +++ b/tools/test-cloud-meta-mock.py @@ -169,7 +169,6 @@ class SocketHTTPServer(HTTPServer): def create_default_resources_for_provider(provider): - mac1 = b"cc:00:00:00:00:01" mac2 = b"cc:00:00:00:00:02" @@ -244,7 +243,6 @@ def create_default_resources_for_provider(provider): def create_default_resources(): - return {p: create_default_resources_for_provider(p) for p in PROVIDERS} diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 00dd9e86c..f274a460c 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -50,7 +50,6 @@ class TestError(AssertionError): class Util: - PY3 = sys.version_info[0] == 3 @staticmethod @@ -509,7 +508,6 @@ class BusErr: class NmUtil: @staticmethod def con_hash_to_connection(con_hash, do_verify=False, do_normalize=False): - x_con = [] for v_setting_name, v_setting in list(con_hash.items()): if isinstance(v_setting_name, (dbus.String, str)): @@ -628,7 +626,6 @@ class NmUtil: class ExportedObj(dbus.service.Object): - DBusInterface = collections.namedtuple("DBusInterface", ["dbus_iface", "props"]) @staticmethod @@ -820,12 +817,10 @@ PRP_DEVICE_INTERFACE_FLAGS = "InterfaceFlags" class Device(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/Devices/" def __init__(self, iface, devtype, ident=None): - if ident is None: ident = iface @@ -1214,7 +1209,6 @@ PRP_WIFI_AP_BANDWIDTH = "Bandwidth" class WifiAp(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/AccessPoint/" @@ -1229,7 +1223,6 @@ class WifiAp(ExportedObj): strength=None, ident=None, ): - ExportedObj.__init__(self, ExportedObj.create_path(WifiAp), ident) NM_AP_FLAGS = getattr(NM, "80211ApSecurityFlags") @@ -1404,12 +1397,10 @@ PRP_VPN_CONNECTION_BANNER = "Banner" class ActiveConnection(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/ActiveConnection/" def __init__(self, device, con_inst, specific_object): - ExportedObj.__init__(self, ExportedObj.create_path(ActiveConnection)) self.device = device @@ -2036,7 +2027,6 @@ PRP_CONNECTION_FILENAME = "Filename" class Connection(ExportedObj): def __init__(self, path_counter, con_hash, do_verify_strict=True): - path = "/org/freedesktop/NetworkManager/Settings/Connection/%s" % (path_counter) ExportedObj.__init__(self, path) @@ -2079,7 +2069,6 @@ class Connection(ExportedObj): return self.get_type() == NM.SETTING_VPN_SETTING_NAME def update_connection(self, con_hash, do_verify_strict): - NmUtil.con_hash_verify(con_hash, do_verify_strict=do_verify_strict) old_uuid = self.get_uuid() @@ -2303,7 +2292,6 @@ PRP_IP4_CONFIG_WINSSERVERS = "WinsServers" class IP4Config(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/IP4Config/" @@ -2502,7 +2490,6 @@ PRP_IP6_CONFIG_DNSPRIORITY = "DnsPriority" class IP6Config(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/IP6Config/" @@ -2676,7 +2663,6 @@ PRP_DHCP4_CONFIG_OPTIONS = "Options" class Dhcp4Config(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/DHCP4Config/" @@ -2717,7 +2703,6 @@ PRP_DHCP6_CONFIG_OPTIONS = "Options" class Dhcp6Config(ExportedObj): - path_counter_next = 1 path_prefix = "/org/freedesktop/NetworkManager/DHCP6Config/"