Repository navigation
Description
Before policyengine-observability 3.0.4, the scope managers that runtime.span(...) and runtime.operation(...) return annotated __exit__ and __aexit__ as returning bool, so Pyright read every span or operation block as possibly suppressing its exception. #712 worked around that in two executor modules by setting each value a block assigns to None before the block and raising a RuntimeError after it when the value was still None:
projects/policyengine-simulation-executor/src/modal/v2_app.py:run_single_simulation_segment_us,run_single_simulation_us,run_single_simulation_ukandcoordinate_reporteach setresult = Nonebefore theirruntime.operation(...)block and raise "... returned no result" after it.projects/policyengine-simulation-executor/src/policyengine_simulation_executor/stage12_runtime/fanout.py:Stage12SegmentRunner.runsetscall = Nonebefore each dispatch span and passes the call through_require_call, which raises "Stage 12 segment dispatch returned no call", and setspayloadsandmergedtoNonebefore the wait and merge spans and raises "... returned no payloads" and "... returned no calculation" after them.
#959 moved every package to 3.0.4, whose scopes are annotated as returning Literal[False] and return False on every path, so each block either assigns its value or its exception reaches the caller. None of the assigned values can be None either: calculate_segment(...).model_dump(...) is a dict, run_single_simulation and coordinate_report are typed dict[str, Any] and return a dict on every path, modal 1.4.2's Function.spawn always returns a FunctionCall, _collect returns a list or raises, and merge_segment_results returns a SimulationCalculation. The presets and checks are therefore unreachable code.
A search of the executor, gateway and entrypoint src directories found no other value set to None before a span or operation block and checked after it. setup_gcp_credentials sets creds_file = None before an ExitStack block that may finish without assigning it, so that one is a real check and stays.
This issue covers:
- tests that run each of those blocks through the scopes of the runtime the services build, passing before and after the removal;
- removing the presets, the checks and
_require_call, with Pyright still reporting no errors.
Activity