diff --git a/sapp/bulk_saver.py b/sapp/bulk_saver.py index 38dd22e..a39d05e 100644 --- a/sapp/bulk_saver.py +++ b/sapp/bulk_saver.py @@ -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 @@ -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. diff --git a/sapp/models.py b/sapp/models.py index 0fbc678..d4477f1 100644 --- a/sapp/models.py +++ b/sapp/models.py @@ -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 @@ -1130,7 +1129,6 @@ def merge(cls, session, items): class TraceFrameLeafAssoc(Base, PrepareMixin, RecordMixin): - __tablename__ = "trace_frame_message_assoc" __table_args__ = BASE_TABLE_ARGS @@ -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"), @@ -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 @@ -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 diff --git a/sapp/pipeline/__init__.py b/sapp/pipeline/__init__.py index e782ed6..44715b1 100644 --- a/sapp/pipeline/__init__.py +++ b/sapp/pipeline/__init__.py @@ -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: @@ -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: diff --git a/sapp/pipeline/parallel_parser.py b/sapp/pipeline/parallel_parser.py index bafd510..4b38017 100644 --- a/sapp/pipeline/parallel_parser.py +++ b/sapp/pipeline/parallel_parser.py @@ -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 diff --git a/sapp/pipeline/propagate_to_crtex_anchors.py b/sapp/pipeline/propagate_to_crtex_anchors.py index c00b594..0a5ba4c 100644 --- a/sapp/pipeline/propagate_to_crtex_anchors.py +++ b/sapp/pipeline/propagate_to_crtex_anchors.py @@ -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 diff --git a/sapp/ui/filters.py b/sapp/ui/filters.py index c977856..7451a09 100644 --- a/sapp/ui/filters.py +++ b/sapp/ui/filters.py @@ -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() ) diff --git a/sapp/ui/interactive.py b/sapp/ui/interactive.py index 0a30bb3..f576f07 100644 --- a/sapp/ui/interactive.py +++ b/sapp/ui/interactive.py @@ -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, diff --git a/sapp/ui/issues.py b/sapp/ui/issues.py index ef20857..44cec90 100644 --- a/sapp/ui/issues.py +++ b/sapp/ui/issues.py @@ -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, diff --git a/sapp/ui/schema.py b/sapp/ui/schema.py index 3b4b6a1..532d408 100644 --- a/sapp/ui/schema.py +++ b/sapp/ui/schema.py @@ -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 = {} diff --git a/sapp/ui/tests/interactive_test.py b/sapp/ui/tests/interactive_test.py index 1a8d371..c474a1f 100644 --- a/sapp/ui/tests/interactive_test.py +++ b/sapp/ui/tests/interactive_test.py @@ -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: diff --git a/sapp/ui/trace.py b/sapp/ui/trace.py index 9c4d174..c3de016 100644 --- a/sapp/ui/trace.py +++ b/sapp/ui/trace.py @@ -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) @@ -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(