1+ import abc
12import enum
2- from abc import abstractmethod
3- from typing import List , Type , Optional
3+ from typing import List , Type , Optional , Any
44
55from sflkit .events .event_file import EventFile
66from sflkit .model .scope import Scope
@@ -43,7 +43,7 @@ def __repr__(self):
4343"""
4444
4545
46- class AnalysisObject :
46+ class AnalysisObject ( abc . ABC ) :
4747 function_finder = None
4848 loop_finder = None
4949 branch_finder = None
@@ -58,17 +58,17 @@ def set_finder(function_finder, loop_finder, branch_finder):
5858 def __init__ (self ):
5959 self .suspiciousness : float = 0
6060 self .last_evaluation : EvaluationResult = EvaluationResult .UNOBSERVED
61- self .hits = dict ()
61+ self .hits : dict [ EventFile , dict [ Optional [ int ], Any ]] = dict ()
6262
6363 def adjust_weight (self , event_file : EventFile , weight : float ):
6464 pass
6565
66- @abstractmethod
66+ @abc . abstractmethod
6767 def serialize (self ) -> dict :
6868 pass
6969
7070 @staticmethod
71- @abstractmethod
71+ @abc . abstractmethod
7272 def deserialize (s : dict ) -> "AnalysisObject" :
7373 pass
7474
@@ -82,7 +82,7 @@ def __str__(self):
8282 return f"{ self .analysis_type ()} "
8383
8484 @staticmethod
85- @abstractmethod
85+ @abc . abstractmethod
8686 def analysis_type () -> AnalysisType :
8787 raise NotImplementedError ()
8888
@@ -93,19 +93,19 @@ def analyze(self, passed: List, failed: List):
9393 def calculate (self ):
9494 pass
9595
96- @abstractmethod
96+ @abc . abstractmethod
9797 def finalize (self , passed : List , failed : List ):
9898 raise NotImplementedError ()
9999
100- @abstractmethod
101- def hit (self , id_ , event , scope_ : Scope = None ):
100+ @abc . abstractmethod
101+ def hit (self , id_ : EventFile , event , scope : Scope = None ):
102102 raise NotImplementedError ()
103103
104- @abstractmethod
104+ @abc . abstractmethod
105105 def get_suggestion (self ):
106106 raise NotImplementedError ()
107107
108- @abstractmethod
108+ @abc . abstractmethod
109109 def assign_suspiciousness (self ):
110110 raise NotImplementedError ()
111111
@@ -114,7 +114,7 @@ def handle(event, events: List[Type]):
114114 return any (map (lambda e : isinstance (event , e ), events ))
115115
116116 @staticmethod
117- @abstractmethod
117+ @abc . abstractmethod
118118 def events () -> List [Type ]:
119119 raise NotImplementedError ()
120120
0 commit comments