Skip to content

Commit

Permalink
apply Black 2024 style in fbcode (6/16)
Browse files Browse the repository at this point in the history
Summary:
Formats the covered files with pyfmt.

paintitblack

Reviewed By: aleivag

Differential Revision: D54447740

fbshipit-source-id: e6562ba4b2cd9046d8912400ae69b2a7baa94c1e
  • Loading branch information
amyreese authored and facebook-github-bot committed Mar 3, 2024
1 parent 795346f commit 9bb556e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions openr/py/openr/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ def print_config(self, lm_config: openr_types.LinkMonitorState):
print(printing.render_vertical_table([["linkMetricOverrides:"]]))
column_labels = ["Interface", "Metric Override"]
rows = []
for (k, v) in sorted(lm_config.linkMetricOverrides.items()):
for k, v in sorted(lm_config.linkMetricOverrides.items()):
rows.append([k, v])
print(printing.render_horizontal_table(rows, column_labels=column_labels))

print(printing.render_vertical_table([["adjMetricOverrides:"]]))
column_labels = ["Adjacency", "Metric Override"]
rows = []
for (k, v) in sorted(lm_config.adjMetricOverrides.items()):
for k, v in sorted(lm_config.adjMetricOverrides.items()):
adj_str = k.nodeName + " " + k.ifName
rows.append([adj_str, v])
print(printing.render_horizontal_table(rows, column_labels=column_labels))
Expand Down
10 changes: 4 additions & 6 deletions openr/py/openr/cli/commands/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,7 @@ 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 Expand Up @@ -829,9 +827,9 @@ async def fetch(

# Create filter
route_filter = ctrl_types.ReceivedRouteFilter(
prefixes=[ipnetwork.ip_str_to_prefix(p) for p in prefixes]
if prefixes
else None,
prefixes=(
[ipnetwork.ip_str_to_prefix(p) for p in prefixes] if prefixes else None
),
nodeName=node,
areaName=area,
)
Expand Down
8 changes: 4 additions & 4 deletions openr/py/openr/cli/commands/kvstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def iter_publication(
@param: parse_func - function: the parsing function
"""

for (key, value) in sorted(publication.keyVals.items(), key=lambda x: x[0]):
for key, value in sorted(publication.keyVals.items(), key=lambda x: x[0]):
reported_node_name = key.split(":")[1]
if "all" not in nodes and reported_node_name not in nodes:
continue
Expand Down Expand Up @@ -165,7 +165,7 @@ def print_peers(self, host_id: str, peers_list: Dict[str, Any]) -> None:
]

for area, peers in peers_list.items():
for (peer, peerspec) in sorted(peers.items(), key=lambda x: x[0]):
for peer, peerspec in sorted(peers.items(), key=lambda x: x[0]):
elapsed_time = ""
flaps = ""
if peerspec.stateElapsedTimeMs is not None:
Expand Down Expand Up @@ -1376,8 +1376,8 @@ def _validate_peer_state(
"""

invalid_peers = defaultdict(dict)
for (area, peers) in area_to_peers.items():
for (peer_name, peer_spec) in peers.items():
for area, peers in area_to_peers.items():
for peer_name, peer_spec in peers.items():
if peer_spec.state != KvStorePeerState.INITIALIZED:
invalid_peers[area][peer_name] = peer_spec

Expand Down
6 changes: 3 additions & 3 deletions openr/py/openr/cli/commands/prefix_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def get_advertised_route_filter(
prefixes: List[str], prefix_type: Optional[str]
) -> ctrl_types.AdvertisedRouteFilter:
return ctrl_types.AdvertisedRouteFilter(
prefixes=[ipnetwork.ip_str_to_prefix(p) for p in prefixes]
if prefixes
else None,
prefixes=(
[ipnetwork.ip_str_to_prefix(p) for p in prefixes] if prefixes else None
),
prefixType=to_thrift_prefix_type(prefix_type) if prefix_type else None,
)

Expand Down
4 changes: 2 additions & 2 deletions openr/py/openr/cli/tests/kvstore/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _find_validation_string(
If there is no next validation string, returns None
"""

for (idx, line) in enumerate(stdout_lines[start_idx:], start_idx):
for idx, line in enumerate(stdout_lines[start_idx:], start_idx):
if re.match(r"\[Kvstore\]", line):
return idx

Expand All @@ -226,7 +226,7 @@ def _get_keyval_lines(
"""

key_start_idx = None
for (idx, line) in enumerate(
for idx, line in enumerate(
stdout_lines[validation_str_idx:], validation_str_idx
):
if re.match("Key", line):
Expand Down
2 changes: 1 addition & 1 deletion openr/py/openr/cli/utils/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def iter_dbs(
@param: nodes - set: the set of nodes for parsing
@param: parse_func - function: the parsing function
"""
for (node, db) in sorted(dbs.items()):
for node, db in sorted(dbs.items()):
if "all" not in nodes and node not in nodes:
continue
parse_func(container, db)
Expand Down
6 changes: 2 additions & 4 deletions openr/py/openr/cli/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def build_global_adj_db(resp):
# map: (node) -> AdjacencyDatabase)
global_adj_db = {}

for (key, value) in resp.keyVals.items():
for key, value in resp.keyVals.items():
if not key.startswith(Consts.ADJ_DB_MARKER):
continue
adj_db = deserialize_thrift_py_object(
Expand Down Expand Up @@ -452,9 +452,7 @@ 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,
Union[List[openr_types_py.Adjacency], Sequence[openr_types.Adjacency]],
Expand Down

0 comments on commit 9bb556e

Please sign in to comment.