Skip to content

Commit

Permalink
Convert FBCODE to use the Ruff Formatter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Thomas Polasek authored and facebook-github-bot committed Dec 6, 2024
1 parent 03326cc commit 02b7a46
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 35 deletions.
8 changes: 6 additions & 2 deletions openr/py/openr/cli/clis/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

class LMCli:
def __init__(self):

# [Show Cmd]
self.lm.add_command(LMLinksCli().links, name="links")
self.lm.add_command(LMAdjCli().adj, name="adj")
Expand Down Expand Up @@ -252,7 +251,12 @@ class OverrideAdjMetricCli:
@click.option("--quiet", is_flag=True, help="Do not print out the links table")
@click.pass_obj
def override_adj_metric(
cli_opts, node, interface, metric, yes, quiet # noqa: B902
cli_opts,
node,
interface,
metric,
yes,
quiet, # noqa: B902
):
"""
Override the adjacency metric value.
Expand Down
12 changes: 9 additions & 3 deletions openr/py/openr/cli/clis/prefix_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def all(cli_opts: bunch.Bunch, prefix: list[str]) -> None: # noqa: B902
@click.argument("prefix", nargs=-1, type=str, required=False)
@click.pass_obj
def pre_area_policy(
cli_opts: bunch.Bunch, area: str, prefix: list[str] # noqa: B902
cli_opts: bunch.Bunch,
area: str,
prefix: list[str], # noqa: B902
) -> None:
"""
Show pre-policy routes for advertisment of specified area
Expand All @@ -112,7 +114,9 @@ def pre_area_policy(
@click.argument("prefix", nargs=-1, type=str, required=False)
@click.pass_obj
def post_area_policy(
cli_opts: bunch.Bunch, area: str, prefix: list[str] # noqa: B902
cli_opts: bunch.Bunch,
area: str,
prefix: list[str], # noqa: B902
) -> None:
"""
Show post-policy routes that are advertisment to specified area
Expand All @@ -133,7 +137,9 @@ def post_area_policy(
@click.argument("prefix", nargs=-1, type=str, required=False)
@click.pass_obj
def rejected_on_area(
cli_opts: bunch.Bunch, area: str, prefix: list[str] # noqa: B902
cli_opts: bunch.Bunch,
area: str,
prefix: list[str], # noqa: B902
) -> None:
"""
Show routes rejected by area policy on advertisement
Expand Down
5 changes: 3 additions & 2 deletions openr/py/openr/cli/commands/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async def _run(
*args,
**kwargs,
) -> None:

adj_dbs = await client.getDecisionAdjacenciesFiltered(
ctrl_types.AdjacenciesFilter(selectAreas=areas)
)
Expand Down Expand Up @@ -563,7 +562,9 @@ async def _run(

return errors

async def get_dbs(self, client: OpenrCtrlCppClient.Async, area: str) -> tuple[
async def get_dbs(
self, client: OpenrCtrlCppClient.Async, area: str
) -> tuple[
Sequence[openr_types.AdjacencyDatabase],
Sequence[ctrl_types.ReceivedRouteDetail],
Mapping[str, kv_store_types.Value],
Expand Down
3 changes: 0 additions & 3 deletions openr/py/openr/cli/commands/fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ async def _run(
*args,
**kwargs,
) -> int:

all_success = True

# fetch openr config for comparison
Expand Down Expand Up @@ -508,7 +507,6 @@ async def _run(
*args,
**kwargs,
) -> None:

initialDb, updates = await client.subscribeAndGetFib()
# Print summary
print(f" Routes for {initialDb.thisNodeName}.")
Expand Down Expand Up @@ -575,7 +573,6 @@ async def _run(
*args,
**kwargs,
) -> None:

subscribers = await client.getSubscriberInfo(StreamSubscriberType.FIB)

# Prepare the table
Expand Down
3 changes: 0 additions & 3 deletions openr/py/openr/cli/commands/kvstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ def print_delta(
delta: bool,
global_dbs: dict,
):

for key, value in msg.keyVals.items():
if value.value is None:
print(f"Traversal List: {msg.nodeIds}")
Expand Down Expand Up @@ -1221,7 +1220,6 @@ async def _run(
*args,
**kwargs,
) -> None:

subscribers = await client.getSubscriberInfo(StreamSubscriberType.KVSTORE)

# Prepare the table
Expand Down Expand Up @@ -1258,7 +1256,6 @@ async def _run(
*args,
**kwargs,
) -> bool:

is_pass = True

# Get data
Expand Down
10 changes: 6 additions & 4 deletions openr/py/openr/cli/commands/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ async def _run(
*args,
**kwargs,
) -> bool:

is_pass = True

# Get Data
Expand Down Expand Up @@ -602,10 +601,14 @@ def _validate_interface_regex(
redistr_regexes = area.redistribute_interface_regexes

passes_incl_regexes = self.validate_regexes(
incl_regexes, [interface], True # expect at least one regex match
incl_regexes,
[interface],
True, # expect at least one regex match
)
passes_excl_regexes = self.validate_regexes(
excl_regexes, [interface], False # expect no regex match
excl_regexes,
[interface],
False, # expect no regex match
)
passes_redistr_regexes = self.validate_regexes(
redistr_regexes, [interface], True
Expand All @@ -631,7 +634,6 @@ def _print_interface_validation_info(
self,
invalid_interfaces: dict[str, Any],
) -> None:

click.echo(
self.validation_result_str(
"link monitor", "Interface Regex Check", (len(invalid_interfaces) == 0)
Expand Down
1 change: 0 additions & 1 deletion openr/py/openr/cli/commands/openr.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def run(
*args,
**kwargs,
) -> int:

spark_pass = spark.ValidateCmd(self.cli_opts).run(detail=False)
lm_pass = lm.LMValidateCmd(self.cli_opts).run()
kvstore_pass = kvstore.ValidateCmd(self.cli_opts).run()
Expand Down
5 changes: 0 additions & 5 deletions openr/py/openr/cli/commands/prefix_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ async def _run(
*args,
**kwargs,
) -> None:

# Get data
routes = await self.fetch(client, prefixes, prefix_type)

Expand Down Expand Up @@ -122,7 +121,6 @@ async def _run(
*args,
**kwargs,
) -> None:

# Get data
await self._render(await client.getOriginatedPrefixes(), detailed, tag2name)

Expand Down Expand Up @@ -266,7 +264,6 @@ async def _run(
*args,
**kwargs,
) -> None:

# Get data
routes = await self.fetch(client, route_filter_type, prefixes, prefix_type)

Expand Down Expand Up @@ -321,7 +318,6 @@ async def _run(
*args,
**kwargs,
) -> None:

# Deduce / Validate area
area = await utils.deduce_area(client, area)

Expand Down Expand Up @@ -375,7 +371,6 @@ async def _run(
*args,
**kwargs,
) -> bool:

is_pass = True

# Get Data
Expand Down
3 changes: 0 additions & 3 deletions openr/py/openr/cli/commands/spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ async def _run(
*args,
**kwargs,
) -> None:

# Get data
neighbors = await client.getNeighbors()

Expand All @@ -138,7 +137,6 @@ class ValidateCmd(SparkBaseCmd):
async def _run(
self, client: OpenrCtrlCppClient.Async, detail: bool, *args, **kwards
) -> bool:

is_pass = True

# Get data
Expand Down Expand Up @@ -262,7 +260,6 @@ def _print_neighbor_regex_info(
regexes: dict[str, list[str]],
detail: bool,
) -> None:

click.echo(
self.validation_result_str(
"spark", "neighbor regex matching check", (len(invalid_neighbors) == 0)
Expand Down
1 change: 0 additions & 1 deletion openr/py/openr/cli/tests/fib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def check_printed_routes(
def check_dest_line(
dest_line: str,
) -> Sequence[NextHopThrift] | None:

is_valid_route = False
next_hops = None

Expand Down
2 changes: 0 additions & 2 deletions openr/py/openr/cli/tests/spark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ def test_spark_validate_regex_accept_all(
def test_spark_validate_regex_diff_ids(
self, mocked_openr_client: AsyncMock
) -> None:

# Checking if it passes with different ids and correct areas
mocked_returned_connection = helpers.get_enter_thrift_asyncmock(
mocked_openr_client
Expand Down Expand Up @@ -385,7 +384,6 @@ def test_spark_validate_regex_diff_ids(
def test_spark_validate_regex_accept_none(
self, mocked_openr_client: AsyncMock
) -> None:

# Checking if it fails when no node is accepted
# Also checks if it correclty prints out more than 1 failed neighbor
mocked_returned_connection = helpers.get_enter_thrift_asyncmock(
Expand Down
11 changes: 5 additions & 6 deletions openr/py/openr/cli/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def collate_prefix_keys(
prefix_maps = {}
for key, value in sorted(kvstore_keyvals.items()):
if key.startswith(Consts.PREFIX_DB_MARKER):

node_name = key.split(":")[1]
if value.value:
prefix_db = deserialize(openr_types.PrefixDatabase, value.value)
Expand Down Expand Up @@ -442,7 +441,9 @@ def build_global_prefix_db(resp):
return global_prefix_db


def dump_adj_db_full(global_adj_db, adj_db, bidir) -> tuple[
def dump_adj_db_full(
global_adj_db, adj_db, bidir
) -> tuple[
int,
bool,
list[openr_types_py.Adjacency] | Sequence[openr_types.Adjacency],
Expand Down Expand Up @@ -1466,7 +1467,6 @@ def compare_route_db(
sources: list[str],
quiet: bool = False,
) -> tuple[bool, list[str]]:

extra_routes_in_a = routes_difference(routes_a, routes_b, route_type)
extra_routes_in_b = routes_difference(routes_b, routes_a, route_type)
diff_prefixes = prefixes_with_different_nexthops(routes_a, routes_b, route_type)
Expand Down Expand Up @@ -1722,9 +1722,8 @@ def print_unicast_routes(

def build_unicast_route(
route: network_types.UnicastRoute | network_types_py.UnicastRoute,
filter_for_networks: None | (
list[ipaddress.IPv4Network | ipaddress.IPv6Network]
) = None,
filter_for_networks: None
| (list[ipaddress.IPv4Network | ipaddress.IPv6Network]) = None,
filter_exact_match: bool = False,
nexthops_to_neighbor_names: dict[bytes, str] | None = None,
) -> tuple[str, list[str]] | None:
Expand Down

0 comments on commit 02b7a46

Please sign in to comment.