Skip to content

Commit a47ae12

Browse files
Merge pull request #156 from stealthrocket/mypy-1.10.0
mypy: upgrade to 1.10.0
2 parents bfdd64b + 8a92dbf commit a47ae12

File tree

18 files changed

+167
-168
lines changed

18 files changed

+167
-168
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fmt-check:
3030
exit $$((isort_status + black_status))
3131

3232
typecheck:
33-
$(PYTHON) -m mypy src tests
33+
$(PYTHON) -m mypy --check-untyped-defs src tests examples
3434

3535
unittest:
3636
$(PYTHON) -m pytest tests

examples/auto_retry/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_app(self):
2525
from .app import app, dispatch
2626

2727
# Setup a fake Dispatch server.
28-
endpoint_client = EndpointClient.from_app(app)
28+
endpoint_client = EndpointClient(TestClient(app))
2929
dispatch_service = DispatchService(endpoint_client, collect_roundtrips=True)
3030
with DispatchServer(dispatch_service) as dispatch_server:
3131
# Use it when dispatching function calls.

examples/getting_started/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_app(self):
2424
from .app import app, dispatch
2525

2626
# Setup a fake Dispatch server.
27-
endpoint_client = EndpointClient.from_app(app)
27+
endpoint_client = EndpointClient(TestClient(app))
2828
dispatch_service = DispatchService(endpoint_client, collect_roundtrips=True)
2929
with DispatchServer(dispatch_service) as dispatch_server:
3030
# Use it when dispatching function calls.

examples/github_stats/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_app(self):
2424
from .app import app, dispatch
2525

2626
# Setup a fake Dispatch server.
27-
endpoint_client = EndpointClient.from_app(app)
27+
endpoint_client = EndpointClient(TestClient(app))
2828
dispatch_service = DispatchService(endpoint_client, collect_roundtrips=True)
2929
with DispatchServer(dispatch_service) as dispatch_server:
3030
# Use it when dispatching function calls.

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lambda = ["awslambdaric"]
2626
dev = [
2727
"black >= 24.1.0",
2828
"isort >= 5.13.2",
29-
"mypy >= 1.8.0",
29+
"mypy >= 1.10.0",
3030
"pytest==8.0.0",
3131
"fastapi >= 0.109.0",
3232
"coverage >= 7.4.1",
@@ -58,7 +58,15 @@ src_paths = ["src"]
5858
omit = ["*_pb2_grpc.py", "*_pb2.py", "tests/*", "examples/*", "src/buf/*"]
5959

6060
[tool.mypy]
61-
exclude = ['^src/buf', '^tests/examples']
61+
exclude = [
62+
'^src/buf',
63+
'^tests/examples',
64+
# mypy 1.10.0 reports false positives for these two files:
65+
# src/dispatch/sdk/v1/function_pb2_grpc.py:74: error: Module has no attribute "experimental" [attr-defined]
66+
# src/dispatch/sdk/v1/dispatch_pb2_grpc.py:80: error: Module has no attribute "experimental" [attr-defined]
67+
'^src/dispatch/sdk/v1/function_pb2_grpc.py',
68+
'^src/dispatch/sdk/v1/dispatch_pb2_grpc.py',
69+
]
6270

6371
[tool.pytest.ini_options]
6472
testpaths = ['tests']

src/dispatch/experimental/durable/function.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ def __getstate__(self):
137137
if frame_state < FRAME_CLEARED:
138138
print(f"IP = {ip}")
139139
print(f"SP = {sp}")
140-
for i, (is_null, value) in enumerate(stack):
140+
for i, (is_null, value) in enumerate(
141+
stack if stack is not None else []
142+
):
141143
if is_null:
142144
print(f"stack[{i}] = NULL")
143145
else:
144146
print(f"stack[{i}] = {value}")
145147
print(f"BP = {bp}")
146-
for i, block in enumerate(blocks):
148+
for i, block in enumerate(blocks if blocks is not None else []):
147149
print(f"block[{i}] = {block}")
148150
print()
149151

src/dispatch/experimental/durable/registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def __setstate__(self, state):
4040
f"hash mismatch for function {key}: {code_hash} vs. expected {rfn.hash}"
4141
)
4242

43-
self.fn = rfn.fn
43+
# mypy 1.10.0 seems to report a false positive here:
44+
# error: Incompatible types in assignment (expression has type "FunctionType", variable has type "MethodType") [assignment]
45+
self.fn = rfn.fn # type: ignore
4446
self.key = key
4547
self.filename = filename
4648
self.lineno = lineno

src/dispatch/function.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,11 @@ def primitive_func(input: Input) -> Output:
256256
return OneShotScheduler(func).run(input)
257257

258258
primitive_func.__qualname__ = f"{name}_primitive"
259-
primitive_func = durable(primitive_func)
259+
durable_primitive_func = durable(primitive_func)
260260

261-
wrapped_func = Function[P, T](self.endpoint, self.client, name, primitive_func)
261+
wrapped_func = Function[P, T](
262+
self.endpoint, self.client, name, durable_primitive_func
263+
)
262264
self._register(name, wrapped_func)
263265
return wrapped_func
264266

src/dispatch/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def do_POST(self):
117117
)
118118
max_age = timedelta(minutes=5)
119119
try:
120-
verify_request(signed_request, verification_key, max_age)
120+
verify_request(signed_request, self.verification_key, max_age)
121121
except ValueError as e:
122122
self.send_error_response_unauthenticated(str(e))
123123
return

src/dispatch/status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __str__(self):
8383
_OUTPUT_TYPES: Dict[Type[Any], Callable[[Any], Status]] = {}
8484

8585

86-
def status_for_error(error: Exception) -> Status:
86+
def status_for_error(error: BaseException) -> Status:
8787
"""Returns a Status that corresponds to the specified error."""
8888
# See if the error matches one of the registered types.
8989
handler = _find_handler(error, _ERROR_TYPES)

0 commit comments

Comments
 (0)