Skip to content

Commit

Permalink
Convert directory fbcode/tools 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 in pyfmt

ruff_dog

If this diff causes merge conflicts when rebasing, please run
`hg status -n -0 --change . -I '**/*.{py,pyi}' | xargs -0 arc pyfmt`
on your diff, and amend any changes before rebasing onto latest.
That should help reduce or eliminate any merge conflicts.

allow-large-files

Reviewed By: igorsugak

Differential Revision: D66677210

fbshipit-source-id: cd523e0785cfe98f22bdefff1d6f679a22e93329
  • Loading branch information
Thomas Polasek authored and facebook-github-bot committed Dec 4, 2024
1 parent 672e60e commit c569081
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 23 deletions.
6 changes: 3 additions & 3 deletions sapp/bulk_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

# pyre-strict

"""Bulk saving objects for performance
"""
"""Bulk saving objects for performance"""

import logging
from typing import Any, Dict, List, Optional, Type
Expand Down Expand Up @@ -201,7 +200,8 @@ def _save_batch_and_handle_key_conflicts(
dialect = database.engine.dialect.name
if dialect == "mysql":
statement = (
mysql_insert(cls).values(records_to_save)
mysql_insert(cls)
.values(records_to_save)
# Setting a field to itself is a standard way of doing a no-op in
# case of existing rows. This is better than using "INSERT IGNORE"
# because that ignores all sorts of other errors too.
Expand Down
5 changes: 0 additions & 5 deletions sapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def process_result_value(self, value, dialect) -> IssueDBID:


class IssueInstanceTraceFrameAssoc(Base, PrepareMixin, RecordMixin):

__tablename__ = "issue_instance_trace_frame_assoc"
__table_args__ = BASE_TABLE_ARGS

Expand Down Expand Up @@ -1130,7 +1129,6 @@ def merge(cls, session, items):


class TraceFrameLeafAssoc(Base, PrepareMixin, RecordMixin):

__tablename__ = "trace_frame_message_assoc"
__table_args__ = BASE_TABLE_ARGS

Expand Down Expand Up @@ -1185,7 +1183,6 @@ class IssueInstanceFixInfo(Base, PrepareMixin, RecordMixin):


class TraceFrame(Base, PrepareMixin, RecordMixin):

__tablename__ = "trace_frames"
__table_args__ = (
Index("ix_traceframe_run_caller_port", "run_id", "caller_id", "caller_port"),
Expand Down Expand Up @@ -1354,7 +1351,6 @@ def type_intervals_match_or_ignored(
# of traces leading to some other leaf. TraceFrameAnnotationTraceFrameAssoc
# contains the first hop towards that leaf..
class TraceFrameAnnotation(Base, PrepareMixin, RecordMixin):

__tablename__ = "trace_frame_annotations"
__table_args__ = BASE_TABLE_ARGS

Expand Down Expand Up @@ -1419,7 +1415,6 @@ class TraceFrameAnnotation(Base, PrepareMixin, RecordMixin):
# IssueInstanceTraceFrameAssoc, which indicates the first hop trace frame from
# the issue instance.
class TraceFrameAnnotationTraceFrameAssoc(Base, PrepareMixin, RecordMixin):

__tablename__ = "trace_frame_annotation_trace_frame_assoc"
__table_args__ = BASE_TABLE_ARGS

Expand Down
4 changes: 2 additions & 2 deletions sapp/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def parse_trace_feature(feature: Union[str, Dict[str, Any]]) -> ParseTraceFeatur


def flatten_feature_to_parse_trace_feature(
feature: Dict[str, Any]
feature: Dict[str, Any],
) -> Iterable[ParseTraceFeature]:
for key, value in feature.items():
if isinstance(value, str) and value:
Expand All @@ -197,7 +197,7 @@ def flatten_feature_to_parse_trace_feature(


def flatten_features_to_parse_trace_feature(
features: Iterable[Dict[str, Any]]
features: Iterable[Dict[str, Any]],
) -> List[ParseTraceFeature]:
ret = []
for feature in features:
Expand Down
2 changes: 1 addition & 1 deletion sapp/pipeline/parallel_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# serializable data. And as a single arg, as far as I can tell. Which is why the
# args type looks so silly.
def parse(
args: Tuple[Tuple[Type[BaseParser], Set[str], Metadata], str]
args: Tuple[Tuple[Type[BaseParser], Set[str], Metadata], str],
) -> List[Union[ParseConditionTuple, ParseIssueTuple]]:
(base_parser, repo_dirs, metadata), path = args

Expand Down
6 changes: 3 additions & 3 deletions sapp/pipeline/propagate_to_crtex_anchors.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def _update_visited(
kind = self.graph.get_shared_text_by_local_id(shared_text).kind
if kind is SharedTextKind.FEATURE:
trace_length_to_use = 0
visited_frame[sink_kind].shared_text_trace_lengths[
shared_text
] = trace_length_to_use
visited_frame[sink_kind].shared_text_trace_lengths[shared_text] = (
trace_length_to_use
)

def _propagate_shared_texts(self, instance: IssueInstance) -> None:
"""Propagate the source kinds and features of this issue instance to all
Expand Down
1 change: 0 additions & 1 deletion sapp/ui/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def all_filters(session: Session) -> List[Filter]:


def save_filter(session: Session, filter: Filter) -> None:

existing = (
session.query(FilterRecord).filter(FilterRecord.name == filter.name).first()
)
Expand Down
2 changes: 1 addition & 1 deletion sapp/ui/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ def _get_leaves_issue_instance(
) -> Set[str]:
ids = [
int(id)
for id, in session.query(SharedText.id)
for (id,) in session.query(SharedText.id)
.distinct(SharedText.id)
.join(
IssueInstanceSharedTextAssoc,
Expand Down
2 changes: 1 addition & 1 deletion sapp/ui/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def _get_leaves(
) -> Set[str]:
message_ids = [
int(id)
for id, in session.query(SharedText.id)
for (id,) in session.query(SharedText.id)
.distinct(SharedText.id)
.join(
IssueInstanceSharedTextAssoc,
Expand Down
1 change: 0 additions & 1 deletion sapp/ui/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def create_filter_from_query(
max_trace_length_to_sources: Optional[int],
is_new_issue: Optional[bool],
) -> Filter:

restructured_features: List[Dict[str, Union[str, List[str]]]] = []
for filtering_condition in features or []:
feature_entry = {}
Expand Down
6 changes: 3 additions & 3 deletions sapp/ui/tests/interactive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2567,9 +2567,9 @@ def testDetails(self) -> None:
self.fakes.issue(callable="call3"),
self.fakes.issue(callable="call2"),
]
self.fakes.instance(issue_id=issues[0].id, callable="call2"),
self.fakes.instance(issue_id=issues[1].id, callable="call3"),
self.fakes.instance(issue_id=issues[2].id, callable="call2"),
(self.fakes.instance(issue_id=issues[0].id, callable="call2"),)
(self.fakes.instance(issue_id=issues[1].id, callable="call3"),)
(self.fakes.instance(issue_id=issues[2].id, callable="call2"),)
self.fakes.save_all(self.db)

with self.db.make_session(expire_on_commit=False) as session:
Expand Down
4 changes: 2 additions & 2 deletions sapp/ui/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def get_leaves_trace_frame(
) -> Set[str]:
ids = [
int(id)
for id, in session.query(SharedText.id)
for (id,) in session.query(SharedText.id)
.distinct(SharedText.id)
.join(TraceFrameLeafAssoc, SharedText.id == TraceFrameLeafAssoc.leaf_id)
.filter(TraceFrameLeafAssoc.trace_frame_id == trace_frame_id)
Expand All @@ -442,7 +442,7 @@ def trace_kind_to_shared_text_kind(trace_kind: Optional[TraceKind]) -> SharedTex


def create_trace_tuples(
navigation: Iterable[Tuple[TraceFrameQueryResult, int]]
navigation: Iterable[Tuple[TraceFrameQueryResult, int]],
) -> List[TraceTuple]:
return [
TraceTuple(
Expand Down

0 comments on commit c569081

Please sign in to comment.