Skip to content

Commit 5d26eb3

Browse files
authored
chore: enable more mypy checks (#52)
1 parent 1fb1565 commit 5d26eb3

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

pyproject.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments = true
6464
[tool.mypy]
6565
packages = ["pywrangler"]
6666
python_version = "3.12"
67-
warn_return_any = true
68-
warn_unused_configs = true
69-
disallow_untyped_defs = true
70-
disallow_incomplete_defs = true
71-
disallow_untyped_decorators = false
72-
check_untyped_defs = true
73-
disallow_any_generics = false
67+
68+
show_error_codes = true
69+
70+
strict = true
71+
warn_unreachable = true
7472
no_implicit_optional = true
7573

7674
[[tool.mypy.overrides]]

src/pywrangler/utils.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
import click
1111
import pyjson5
12-
from rich.logging import Console, RichHandler
12+
from rich.console import Console
13+
from rich.logging import RichHandler
1314
from rich.theme import Theme
1415

1516
from .metadata import PYTHON_COMPAT_VERSIONS
@@ -59,7 +60,7 @@ def write_success(msg: str) -> None:
5960
def 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

222224
def _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

Comments
 (0)