From b63e7cc45ed7596f5f1ae82da8e5e99b068769ec Mon Sep 17 00:00:00 2001 From: Thomas Polasek Date: Fri, 6 Dec 2024 10:37:02 -0800 Subject: [PATCH] Convert FBCODE to use the Ruff Formatter Summary: Converts the directory specified to use the Ruff formatter. This is the last big diff to convert all of Fbcode to Ruff. pomsky_fix_bugs drop-conflicts bypass-github-export-checks allow-large-files Reviewed By: amyreese Differential Revision: D66886610 fbshipit-source-id: 8276a7f6164efec189ca0b87e535543ed5bc3615 --- fboss/agent/tools/fboss_route.py | 4 +--- fboss/lib/bsp/bspmapping/run-helper.py | 8 ++++---- fboss/oss/scripts/package-fboss.py | 1 - fboss/py/fboss/cli/cli.py | 1 - fboss/py/fboss/cli/commands/aggregate_port.py | 3 --- fboss/py/fboss/cli/commands/port.py | 1 - fboss/util/cmis_200g_datapath_fix.py | 1 + fboss/util/find_sai_spec_symbols_in_fboss.py | 10 +++++----- 8 files changed, 11 insertions(+), 18 deletions(-) diff --git a/fboss/agent/tools/fboss_route.py b/fboss/agent/tools/fboss_route.py index 407fb60fdad03..8362c8ea9d442 100644 --- a/fboss/agent/tools/fboss_route.py +++ b/fboss/agent/tools/fboss_route.py @@ -102,9 +102,7 @@ def list_optics(args): def list_ports(args): details = args.details with get_client(args) as client: - for idx, intf in client.getPortStatus( - list(range(1, 65)) - ).items(): # noqa: B301 T25377293 Grandfathered in + for idx, intf in client.getPortStatus(list(range(1, 65))).items(): # noqa: B301 T25377293 Grandfathered in stats = "" if details: stats = " (%s)" % client.getPortStats(idx) diff --git a/fboss/lib/bsp/bspmapping/run-helper.py b/fboss/lib/bsp/bspmapping/run-helper.py index 78edd7799e01d..47b5d4e729286 100755 --- a/fboss/lib/bsp/bspmapping/run-helper.py +++ b/fboss/lib/bsp/bspmapping/run-helper.py @@ -2,13 +2,13 @@ # (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. """ - Helper script for building and running the BSP Mapping script generation. +Helper script for building and running the BSP Mapping script generation. - This should be run from the root of the FBOSS repository. +This should be run from the root of the FBOSS repository. - Sample invocation: +Sample invocation: - [~/src/fboss-repo]$ ./fboss/lib/bsp/bspmapping/run-helper.py + [~/src/fboss-repo]$ ./fboss/lib/bsp/bspmapping/run-helper.py """ import os diff --git a/fboss/oss/scripts/package-fboss.py b/fboss/oss/scripts/package-fboss.py index 8889208e76a6d..76fb02b21d3ad 100755 --- a/fboss/oss/scripts/package-fboss.py +++ b/fboss/oss/scripts/package-fboss.py @@ -59,7 +59,6 @@ class PackageFboss: } def __init__(self): - self.scratch_path = args.scratch_path self.git_path = os.path.join( self.scratch_path, "repos/github.com-facebook-fboss.git" diff --git a/fboss/py/fboss/cli/cli.py b/fboss/py/fboss/cli/cli.py index b7b4e7bd0dec6..5882746f405fc 100755 --- a/fboss/py/fboss/cli/cli.py +++ b/fboss/py/fboss/cli/cli.py @@ -850,7 +850,6 @@ def add_modules(main_func): if __name__ == "__main__": - # -- Add sub-commands to "Main" -- # add_modules(main) diff --git a/fboss/py/fboss/cli/commands/aggregate_port.py b/fboss/py/fboss/cli/commands/aggregate_port.py index 0fa1fa97ddfe3..2eb899b1a6102 100644 --- a/fboss/py/fboss/cli/commands/aggregate_port.py +++ b/fboss/py/fboss/cli/commands/aggregate_port.py @@ -19,7 +19,6 @@ def get_port_num(port: str) -> str: - port_num_match = AGG_PORT_NUM_RE.match(port) if port_num_match: return port_num_match.group("port_num") @@ -28,7 +27,6 @@ def get_port_num(port: str) -> str: def _should_print_agg_port_info(target_port_num: str, agg_port) -> bool: - # If there's no target set we print the info for all ports if not target_port_num: return True @@ -87,7 +85,6 @@ def legacy_format(self, response): ) def run(self, port): - port_num = get_port_num(port) if port and not port_num: print(f"Invalid aggregate port name: {port}") diff --git a/fboss/py/fboss/cli/commands/port.py b/fboss/py/fboss/cli/commands/port.py index 1a8ac8a9a3ff7..bc6500282bdb7 100644 --- a/fboss/py/fboss/cli/commands/port.py +++ b/fboss/py/fboss/cli/commands/port.py @@ -28,7 +28,6 @@ class PortDetailsCmd(cmds.FbossCmd): def run(self, ports, show_down=True): - with self._create_agent_client() as client: try: resp = client.getAllPortInfo() diff --git a/fboss/util/cmis_200g_datapath_fix.py b/fboss/util/cmis_200g_datapath_fix.py index cfb5e01ee6a77..4730c970d9046 100644 --- a/fboss/util/cmis_200g_datapath_fix.py +++ b/fboss/util/cmis_200g_datapath_fix.py @@ -7,6 +7,7 @@ state. This script identifies all such bad ports on a given list of swicthes and remediates them by re-applying the optics Stage set 0 config once again """ + import subprocess from time import sleep diff --git a/fboss/util/find_sai_spec_symbols_in_fboss.py b/fboss/util/find_sai_spec_symbols_in_fboss.py index b9b7fd0a816f0..63d7258812df8 100755 --- a/fboss/util/find_sai_spec_symbols_in_fboss.py +++ b/fboss/util/find_sai_spec_symbols_in_fboss.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 """ - Scan every word in the SAI Spec for all SAI symbols of interest => Set1. - Scan every word in the FBOSS SAI API code for all SAI symbols of interest => Set2. - Print intersection of Set1 and Set2. +Scan every word in the SAI Spec for all SAI symbols of interest => Set1. +Scan every word in the FBOSS SAI API code for all SAI symbols of interest => Set2. +Print intersection of Set1 and Set2. - Sample invocation: +Sample invocation: - fboss/util/find_sai_spec_symbols_in_fboss.py $HOME/local/github/sai.git/inc $HOME/fbsource/fbcode/fboss/agent/hw/sai/api +fboss/util/find_sai_spec_symbols_in_fboss.py $HOME/local/github/sai.git/inc $HOME/fbsource/fbcode/fboss/agent/hw/sai/api """ import argparse