@@ -16,10 +16,12 @@ def __enum(table: dict, key: str, enum: Any, default: int = 0) -> Any:
1616 return enum (default )
1717 try :
1818 for i in range (100000 ):
19- if str (enum (i )).split ('.' )[- 1 ].lower () == table [key ].lower ():
19+ if str (enum (i )).split ("." )[- 1 ].lower () == table [key ].lower ():
2020 return enum (i )
2121 except ValueError :
22- raise ConfigParsingException (f"Invalid value { repr (table [key ])} for key '{ key } '." )
22+ raise ConfigParsingException (
23+ f"Invalid value { repr (table [key ])} for key '{ key } '."
24+ )
2325
2426
2527def __str (table : dict , key : str , default : str = "" ) -> str :
@@ -51,9 +53,9 @@ def __table(table: dict, key: str) -> dict:
5153
5254
5355def __team (table : dict ) -> int :
54- if ' team' not in table :
56+ if " team" not in table :
5557 return 0
56- v = table [' team' ]
58+ v = table [" team" ]
5759 if isinstance (v , str ):
5860 if v .lower () == "blue" :
5961 return 0
@@ -62,7 +64,9 @@ def __team(table: dict) -> int:
6264 if isinstance (v , int ):
6365 if 0 <= v <= 1 :
6466 return v
65- raise ConfigParsingException (f"'team' has value { repr (v )} . Expected a 0, 1, \" blue\" , or \" orange\" ." )
67+ raise ConfigParsingException (
68+ f'\' team\' has value { repr (v )} . Expected a 0, 1, "blue", or "orange".'
69+ )
6670
6771
6872def load_match_config (config_path : Path | str ) -> flat .MatchConfiguration :
@@ -83,7 +87,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
8387 name = __str (car_table , "name" )
8488 team = __team (car_table )
8589 loadout_file = __str (car_table , "loadout_file" ) or None
86- skill = __enum (car_table , "skill" , flat .PsyonixSkill , int (flat .PsyonixSkill .AllStar ))
90+ skill = __enum (
91+ car_table , "skill" , flat .PsyonixSkill , int (flat .PsyonixSkill .AllStar )
92+ )
8793 variant = __str (car_table , "type" , "rlbot" ).lower ()
8894
8995 match variant :
@@ -97,14 +103,16 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
97103 logger .warning ("PartyMember player type is not supported yet." )
98104 variety , use_config = flat .PartyMember , False
99105 case t :
100- raise ConfigParsingException (f"Invalid player type { repr (t )} for player { len (players )} ." )
106+ raise ConfigParsingException (
107+ f"Invalid player type { repr (t )} for player { len (players )} ."
108+ )
101109
102110 if use_config and car_config :
103111 abs_config_path = (config_path .parent / car_config ).resolve ()
104- players .append (load_player_config (abs_config_path , variety , team , name , loadout_file ))
112+ players .append (load_player_config (abs_config_path , variety , team , name , loadout_file )) # type: ignore
105113 else :
106114 loadout = load_player_loadout (loadout_file , team ) if loadout_file else None
107- players .append (flat .PlayerConfiguration (variety , name , team , loadout = loadout ))
115+ players .append (flat .PlayerConfiguration (variety , name , team , loadout = loadout )) # type: ignore
108116
109117 scripts = []
110118 for script_table in config .get ("scripts" , []):
@@ -121,14 +129,20 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
121129 overtime = __enum (mutator_table , "overtime" , flat .OvertimeMutator ),
122130 series_length = __enum (mutator_table , "series_length" , flat .SeriesLengthMutator ),
123131 game_speed = __enum (mutator_table , "game_speed" , flat .GameSpeedMutator ),
124- ball_max_speed = __enum (mutator_table , "ball_max_speed" , flat .BallMaxSpeedMutator ),
132+ ball_max_speed = __enum (
133+ mutator_table , "ball_max_speed" , flat .BallMaxSpeedMutator
134+ ),
125135 ball_type = __enum (mutator_table , "ball_type" , flat .BallTypeMutator ),
126136 ball_weight = __enum (mutator_table , "ball_weight" , flat .BallWeightMutator ),
127137 ball_size = __enum (mutator_table , "ball_size" , flat .BallSizeMutator ),
128- ball_bounciness = __enum (mutator_table , "ball_bounciness" , flat .BallBouncinessMutator ),
138+ ball_bounciness = __enum (
139+ mutator_table , "ball_bounciness" , flat .BallBouncinessMutator
140+ ),
129141 boost_amount = __enum (mutator_table , "boost_amount" , flat .BoostAmountMutator ),
130142 rumble = __enum (mutator_table , "rumble" , flat .RumbleMutator ),
131- boost_strength = __enum (mutator_table , "boost_strength" , flat .BoostStrengthMutator ),
143+ boost_strength = __enum (
144+ mutator_table , "boost_strength" , flat .BoostStrengthMutator
145+ ),
132146 gravity = __enum (mutator_table , "gravity" , flat .GravityMutator ),
133147 demolish = __enum (mutator_table , "demolish" , flat .DemolishMutator ),
134148 respawn_time = __enum (mutator_table , "respawn_time" , flat .RespawnTimeMutator ),
@@ -148,7 +162,9 @@ def load_match_config(config_path: Path | str) -> flat.MatchConfiguration:
148162 skip_replays = __bool (match_table , "skip_replays" ),
149163 instant_start = __bool (match_table , "instant_start" ),
150164 mutators = mutators ,
151- existing_match_behavior = __enum (match_table , "existing_match_behavior" , flat .ExistingMatchBehavior ),
165+ existing_match_behavior = __enum (
166+ match_table , "existing_match_behavior" , flat .ExistingMatchBehavior
167+ ),
152168 enable_rendering = __bool (match_table , "enable_rendering" ),
153169 enable_state_setting = __bool (match_table , "enable_state_setting" ),
154170 freeplay = __bool (match_table , "freeplay" ),
@@ -196,8 +212,11 @@ def load_player_loadout(path: Path | str, team: int) -> flat.PlayerLoadout:
196212
197213
198214def load_player_config (
199- path : Path | str , type : flat .CustomBot | flat .Psyonix , team : int ,
200- name_override : str | None = None , loadout_override : Path | str | None = None ,
215+ path : Path | str ,
216+ type : flat .CustomBot | flat .Psyonix ,
217+ team : int ,
218+ name_override : str | None = None ,
219+ loadout_override : Path | str | None = None ,
201220) -> flat .PlayerConfiguration :
202221 """
203222 Reads the bot toml file at the provided path and
@@ -217,9 +236,15 @@ def load_player_config(
217236 if CURRENT_OS == OS .LINUX and "run_command_linux" in settings :
218237 run_command = __str (settings , "run_command_linux" )
219238
220- loadout_path = path .parent / Path (__str (settings , "loadout_file" )) if "loadout_file" in settings else None
239+ loadout_path = (
240+ path .parent / Path (__str (settings , "loadout_file" ))
241+ if "loadout_file" in settings
242+ else None
243+ )
221244 loadout_path = loadout_override or loadout_path
222- loadout = load_player_loadout (loadout_path , team ) if loadout_path is not None else None
245+ loadout = (
246+ load_player_loadout (loadout_path , team ) if loadout_path is not None else None
247+ )
223248
224249 return flat .PlayerConfiguration (
225250 type ,
0 commit comments