77from __future__ import annotations
88
99from collections import deque
10+ from collections .abc import Callable
1011from dataclasses import dataclass , field
11- from typing import TYPE_CHECKING , Callable
12+ from typing import TYPE_CHECKING
1213
1314if TYPE_CHECKING :
1415 from app .models import AnyGame
@@ -62,9 +63,7 @@ def _find_conversion_path(
6263 neighbors .setdefault (src , []).append (tgt )
6364
6465 # BFS to find shortest path
65- queue : deque [tuple [str , list [tuple [str , str ]]]] = deque (
66- [(source_format , [])]
67- )
66+ queue : deque [tuple [str , list [tuple [str , str ]]]] = deque ([(source_format , [])])
6867 visited = {source_format }
6968
7069 while queue :
@@ -80,9 +79,7 @@ def _find_conversion_path(
8079
8180 return None
8281
83- def check (
84- self , game : "AnyGame" , target_format : str , * , quick : bool = False
85- ) -> ConversionCheck :
82+ def check (self , game : AnyGame , target_format : str , * , quick : bool = False ) -> ConversionCheck :
8683 """Check if a game can be converted to target format.
8784
8885 Supports chained conversions (e.g., MAID → EFG → NFG).
@@ -104,9 +101,7 @@ def check(
104101 if not path :
105102 return ConversionCheck (
106103 possible = False ,
107- blockers = [
108- f"No conversion path from { source_format } to { target_format } "
109- ],
104+ blockers = [f"No conversion path from { source_format } to { target_format } " ],
110105 )
111106
112107 # Quick check: only verify path exists and first step is possible
@@ -153,7 +148,7 @@ def check(
153148
154149 return ConversionCheck (possible = True , warnings = all_warnings )
155150
156- def convert (self , game : " AnyGame" , target_format : str ) -> " AnyGame" :
151+ def convert (self , game : AnyGame , target_format : str ) -> AnyGame :
157152 """Convert a game to target format.
158153
159154 Supports chained conversions (e.g., MAID → EFG → NFG).
@@ -175,17 +170,15 @@ def convert(self, game: "AnyGame", target_format: str) -> "AnyGame":
175170 check_result = conversion .can_convert (current_game )
176171
177172 if not check_result .possible :
178- msg = (
179- f"Cannot convert { src } to { tgt } : { ', ' .join (check_result .blockers )} "
180- )
173+ msg = f"Cannot convert { src } to { tgt } : { ', ' .join (check_result .blockers )} "
181174 raise ValueError (msg )
182175
183176 current_game = conversion .convert (current_game )
184177
185178 return current_game
186179
187180 def available_conversions (
188- self , game : " AnyGame" , * , quick : bool = True
181+ self , game : AnyGame , * , quick : bool = True
189182 ) -> dict [str , ConversionCheck ]:
190183 """Get all available conversions for a game.
191184
@@ -212,9 +205,7 @@ def available_conversions(
212205 continue
213206 check_result = self .check (game , target , quick = quick )
214207 # Only include if possible or has a path (even if blocked)
215- if check_result .possible or self ._find_conversion_path (
216- source_format , target
217- ):
208+ if check_result .possible or self ._find_conversion_path (source_format , target ):
218209 results [target ] = check_result
219210
220211 return results
0 commit comments