99
1010import click
1111import pyjson5
12- from rich .logging import Console , RichHandler
12+ from rich .console import Console
13+ from rich .logging import RichHandler
1314from rich .theme import Theme
1415
1516from .metadata import PYTHON_COMPAT_VERSIONS
@@ -59,7 +60,7 @@ def write_success(msg: str) -> None:
5960def run_command (
6061 command : list [str | Path ],
6162 cwd : Path | None = None ,
62- env : dict | None = None ,
63+ env : dict [ str , str | Path ] | None = None ,
6364 check : bool = True ,
6465 capture_output : bool = False ,
6566) -> subprocess .CompletedProcess [str ]:
@@ -215,8 +216,9 @@ def check_wrangler_config() -> None:
215216 raise click .exceptions .Exit (code = 1 )
216217
217218
218- class WranglerConfig (TypedDict ):
219- pass
219+ class WranglerConfig (TypedDict , total = False ):
220+ compatibility_date : str
221+ compatibility_flags : list [str ]
220222
221223
222224def _parse_wrangler_config () -> WranglerConfig :
@@ -265,12 +267,12 @@ def get_python_version() -> Literal["3.12", "3.13"]:
265267 raise click .exceptions .Exit (code = 1 )
266268
267269 compat_flags = config .get ("compatibility_flags" , [])
268-
269- if "compatibility_date" not in config :
270+ compat_date_str = config . get ( "compatibility_date" , None )
271+ if compat_date_str is None :
270272 logger .error ("No compatibility_date specified in wrangler config" )
271273 raise click .exceptions .Exit (code = 1 )
272274 try :
273- compat_date = datetime .strptime (config . get ( "compatibility_date" ) , "%Y-%m-%d" )
275+ compat_date = datetime .strptime (compat_date_str , "%Y-%m-%d" )
274276 except ValueError :
275277 logger .error (
276278 f"Invalid compatibility_date format: { config .get ('compatibility_date' )} "
@@ -294,11 +296,7 @@ def get_python_version() -> Literal["3.12", "3.13"]:
294296 return py_version .version
295297
296298 # For versions with compat_date, also check the date requirement
297- if (
298- py_version .compat_date
299- and compat_date
300- and compat_date >= py_version .compat_date
301- ):
299+ if py_version .compat_date and compat_date >= py_version .compat_date :
302300 return py_version .version
303301
304302 logger .error ("Could not determine Python version from wrangler config" )
0 commit comments