Skip to content

Commit f381505

Browse files
authored
fix: add workers-runtime-sdk as a dependency, update type test (#41)
1 parent 5d26eb3 commit f381505

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "workers-py"
77
version = "1.6.1"
88
description = "A set of libraries and tools for Python Workers"
99
readme = "README.md"
10-
requires-python = ">=3.11"
10+
requires-python = ">=3.12"
1111
classifiers = [
1212
"Programming Language :: Python :: 3",
1313
"License :: OSI Approved :: MIT License",
@@ -19,6 +19,7 @@ dependencies = [
1919
"pyodide-cli",
2020
"pyjson5>=1.6.0",
2121
"pyodide-py",
22+
"workers-runtime-sdk>=0.1.0",
2223
]
2324

2425
[dependency-groups]

tests/test_types.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
dev = [
1818
"mypy>=1.17.1",
1919
"pyodide-py",
20+
"workers-runtime-sdk",
2021
]
2122
2223
[tool.mypy]
@@ -26,16 +27,18 @@
2627
"""
2728

2829
WORKER = """
29-
from typing import TYPE_CHECKING
30-
if TYPE_CHECKING:
31-
from js import Env
32-
33-
class Default:
34-
env: "Env"
35-
async def fetch(self) -> None:
36-
reveal_type(self.env.FOO) # Revealed type is "js.KVNamespace_iface"
30+
from workers import WorkerEntrypoint, Response, Request
31+
32+
33+
class Default(WorkerEntrypoint):
34+
async def fetch(self, request: Request) -> Response:
35+
reveal_type(self.env)
36+
reveal_type(self.env.FOO)
37+
await self.env.FOO.put("bar", "baz")
3738
bar = await self.env.FOO.get("bar")
38-
reveal_type(bar) # Revealed type is "builtins.str | None"
39+
assert bar
40+
reveal_type(bar)
41+
return Response(bar)
3942
"""
4043

4144

@@ -53,7 +56,7 @@ def test_types(tmp_path):
5356
with chdir(tmp_path):
5457
wrangler_types(None, None)
5558
result = run(["uv", "run", "mypy"], capture_output=True, text=True, check=False)
56-
59+
assert 'Revealed type is "js.Env"' in result.stdout
5760
assert 'Revealed type is "js.KVNamespace_iface"' in result.stdout
58-
assert 'Revealed type is "builtins.str | None"' in result.stdout
61+
assert 'Revealed type is "builtins.str"' in result.stdout
5962
assert "Success: no issues found" in result.stdout

0 commit comments

Comments
 (0)