@@ -20,10 +20,10 @@ class TestCase(BaseObject):
2020 output_binary_id : int
2121
2222 def __init__ (self , state : "ConnectionState" , data : TestCaseDict ):
23- self .index = data [ "index" ]
23+ self .index = data . get ( "index" )
2424 self .label = data .get ("label" )
25- self .input_binary_id = data [ "inputBinaryId" ]
26- self .output_binary_id = data [ "outputBinaryId" ]
25+ self .input_binary_id = data . get ( "inputBinaryId" )
26+ self .output_binary_id = data . get ( "outputBinaryId" )
2727
2828 super ().__init__ (state )
2929
@@ -66,14 +66,11 @@ def __init__(
6666 ):
6767 self .clash_of_code = clash_of_code
6868 self .test_case = test_case
69- self .success = data ["comparison" ]["success" ]
70- self .found = (
71- data ["comparison" ]["found" ]
72- if "found" in data ["comparison" ]
73- else data ["output" ]
74- )
69+ comparison = data .get ("comparison" , {})
70+ self .success = comparison .get ("success" )
71+ self .found = comparison .get ("found" , data .get ("output" ))
7572 self .expected = (
76- data [ "output" ] if self .success else data [ " comparison" ][ " expected"]
73+ data . get ( "output" ) if self .success else comparison . get ( " expected")
7774 )
7875
7976 super ().__init__ (state )
@@ -91,14 +88,12 @@ def __init__(
9188 contributor : Optional [PartialCodinGamer ],
9289 data : ContributionDict ,
9390 ):
94- self .type = data [ "type" ]
95- self .status = data [ "status" ]
91+ self .type = data . get ( "type" )
92+ self .status = data . get ( "status" )
9693 self .contributor = contributor
97- self .moderators = (
98- [PartialCodinGamer (state , mod ) for mod in data ["moderators" ]]
99- if "moderators" in data
100- else []
101- )
94+ self .moderators = [
95+ PartialCodinGamer (state , mod ) for mod in data .get ("moderators" , [])
96+ ]
10297
10398 super ().__init__ (state )
10499
@@ -125,19 +120,19 @@ def __init__(
125120 ):
126121 self .clash_of_code = clash_of_code
127122 self .id = data ["id" ]
128- self .initial_id = data [ "initialId" ]
129- self .type = data [ "type" ]
130- self .mode = data [ "mode" ]
131- self .raw_statement = data [ "statement" ]
132- self .stub_generator = data [ "stubGenerator" ]
133- self .duration = data [ "duration" ]
134- self .index = data [ "index" ]
123+ self .initial_id = data . get ( "initialId" )
124+ self .type = data . get ( "type" )
125+ self .mode = data . get ( "mode" )
126+ self .raw_statement = data . get ( "statement" )
127+ self .stub_generator = data . get ( "stubGenerator" )
128+ self .duration = data . get ( "duration" )
129+ self .index = data . get ( "index" )
135130 self .test_cases = sorted (
136- [TestCase (state , case ) for case in data [ "testCases" ] ],
131+ [TestCase (state , case ) for case in data . get ( "testCases" , []) ],
137132 key = lambda t : t .index ,
138133 )
139134 self .available_language_ids = [
140- lang ["id" ] for lang in data [ "availableLanguages" ]
135+ lang ["id" ] for lang in data . get ( "availableLanguages" , [])
141136 ]
142137 contributor = (
143138 PartialCodinGamer (state , data ["contributor" ])
0 commit comments