14
14
#
15
15
16
16
from ..models import ReplayTestingPhase , McapFixture
17
+ from ..logging_config import get_logger
18
+
19
+ _logger_ = get_logger ()
17
20
18
21
19
22
class fixtures :
@@ -23,28 +26,25 @@ def __init__(self, *args, **kwargs):
23
26
# If args/kwargs are provided, treat them as parameters
24
27
self .fixture_list = kwargs .get ("fixture_list" , None )
25
28
26
- def __call__ (self , cls ):
27
- if not hasattr (cls , "input_topics" ):
28
- raise TypeError (f"Class { cls .__name__ } must define a 'input_topics' attribute." )
29
-
30
- if not isinstance (cls .input_topics , list ):
31
- raise TypeError (f"Class { cls .__name } 'input_topics' attribute must be a list." )
32
-
33
- if not all (isinstance (topic , str ) for topic in cls .input_topics ):
34
- raise TypeError (
35
- f"Class { cls .__name } 'input_topics' attribute must be a list of strings."
29
+ def validate_class_variable (self , cls , prop : str , deprecated_variable : str ):
30
+ if hasattr (cls , deprecated_variable ):
31
+ _logger_ .warning (
32
+ f"Class { cls .__name__ } '{ prop } ' attribute is deprecated. See docs for updated usage."
36
33
)
34
+ return
37
35
38
- if not hasattr (cls , "output_topics" ):
39
- raise TypeError (f"Class { cls .__name__ } must define a 'output_topics ' attribute." )
36
+ if not hasattr (cls , prop ):
37
+ raise TypeError (f"Class { cls .__name__ } must define a '{ prop } ' attribute." )
40
38
41
- if not isinstance (cls . output_topics , list ):
42
- raise TypeError (f"Class { cls .__name } 'output_topics ' attribute must be a list." )
39
+ if not isinstance (getattr ( cls , prop ) , list ):
40
+ raise TypeError (f"Class { cls .__name } '{ prop } ' attribute must be a list." )
43
41
44
- if not all (isinstance (topic , str ) for topic in cls .output_topics ):
45
- raise TypeError (
46
- f"Class { cls .__name } 'input_topics' attribute must be a list of strings."
47
- )
42
+ if not all (isinstance (topic , str ) for topic in getattr (cls , prop )):
43
+ raise TypeError (f"Class { cls .__name } '{ prop } ' attribute must be a list of strings." )
44
+
45
+ def __call__ (self , cls ):
46
+ self .validate_class_variable (cls , "required_input_topics" , "input_topics" )
47
+ self .validate_class_variable (cls , "expected_output_topics" , "output_topics" )
48
48
49
49
cls .fixture_list = self .fixture_list
50
50
cls .__annotations__ ["replay_testing_phase" ] = ReplayTestingPhase .FIXTURES
0 commit comments