From 996c222d404ad14e0c520d3abd9395d804b83443 Mon Sep 17 00:00:00 2001 From: Jaden Fix Date: Thu, 8 Oct 2026 20:05:17 -0700 Subject: [PATCH 1/5] Remove the unused main.py stub main.py at the repo root is the "Hello from roe-python!" placeholder left by project init. It is not part of the package (the build ships src/roe only), and nothing imports or runs it. Tested: uv run pytest, ruff check, ruff format --check pass. --- main.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 27c02a6..0000000 --- a/main.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(): - print("Hello from roe-python!") - - -if __name__ == "__main__": - main() From 3590fe92813f216f7a2ac14473c551a0ef766ffb Mon Sep 17 00:00:00 2001 From: Jaden Fix Date: Thu, 8 Oct 2026 20:05:17 -0700 Subject: [PATCH 2/5] Drop the empty TYPE_CHECKING block in policies.py `if TYPE_CHECKING: pass` guards nothing. Remove it and the now unused TYPE_CHECKING import. Tested: uv run pytest, ruff check, ruff format --check pass. --- src/roe/api/policies.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/roe/api/policies.py b/src/roe/api/policies.py index f02c177..024abe4 100644 --- a/src/roe/api/policies.py +++ b/src/roe/api/policies.py @@ -7,7 +7,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any +from typing import Any from uuid import UUID from roe._generated.api.policies import ( @@ -57,10 +57,6 @@ def _parse_policy_version(data: dict[str, Any]) -> PolicyVersion: return PolicyVersion.from_dict(_normalize_policy_version_wire(data)) -if TYPE_CHECKING: - pass - - class PolicyVersionsAPI: """Nested API for policy version operations.""" From db8bd12329ab34e5f73fe3df7758415f355f645b Mon Sep 17 00:00:00 2001 From: Jaden Fix Date: Thu, 8 Oct 2026 20:05:27 -0700 Subject: [PATCH 3/5] Drop never-true empty-chunk checks in agents.py _iter_chunks slices items[i:i + chunk_size] only for i < len(items), so every chunk it yields is non-empty and the three `if not chunk: continue` guards can never fire. Tested: uv run pytest, ruff check, ruff format --check pass. --- src/roe/api/agents.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/roe/api/agents.py b/src/roe/api/agents.py index 3c1cfcd..da92240 100644 --- a/src/roe/api/agents.py +++ b/src/roe/api/agents.py @@ -350,8 +350,6 @@ def retrieve_status_many(self, job_ids: list[str]) -> list[AgentJobStatus]: results: list[AgentJobStatus] = [] is_first_chunk = True for chunk in self._iter_chunks(job_ids, self._MAX_BATCH_SIZE): - if not chunk: - continue if not is_first_chunk: time.sleep(self._agents_api.config.batch_chunk_delay) is_first_chunk = False @@ -375,8 +373,6 @@ def retrieve_result_many( results: list[Any] = [] is_first_chunk = True for chunk in self._iter_chunks(job_ids, self._MAX_BATCH_SIZE): - if not chunk: - continue if not is_first_chunk: time.sleep(self._agents_api.config.batch_chunk_delay) is_first_chunk = False @@ -667,8 +663,6 @@ def run_many( all_job_ids: list[str] = [] is_first_chunk = True for chunk in self._iter_chunks(batch_inputs, self._MAX_BATCH_SIZE): - if not chunk: - continue if not is_first_chunk: time.sleep(self.config.batch_chunk_delay) is_first_chunk = False From c2ea278be3742eb46b5944369e8072f77f7461e9 Mon Sep 17 00:00:00 2001 From: Jaden Fix Date: Thu, 8 Oct 2026 20:05:43 -0700 Subject: [PATCH 4/5] Share one _iter_chunks and _MAX_BATCH_SIZE in agents.py AgentJobsAPI and AgentsAPI each defined an identical _iter_chunks static method and _MAX_BATCH_SIZE = 1000 class attribute. Keep a single private module-level copy of each and call it from both classes. Tested: uv run pytest, ruff check, ruff format --check pass. --- src/roe/api/agents.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/roe/api/agents.py b/src/roe/api/agents.py index da92240..41e6e1e 100644 --- a/src/roe/api/agents.py +++ b/src/roe/api/agents.py @@ -109,6 +109,14 @@ from roe.utils.generated_request import request_json, request_raw +_MAX_BATCH_SIZE = 1000 + + +def _iter_chunks(items, chunk_size: int): + for i in range(0, len(items), chunk_size): + yield items[i : i + chunk_size] + + def _build_run_headers( idempotency_key: str | None = None, skip_cache: bool = False, @@ -273,8 +281,6 @@ def delete(self, agent_id: str, version_id: str) -> None: class AgentJobsAPI: """Nested API for agent job operations.""" - _MAX_BATCH_SIZE = 1000 - def __init__(self, agents_api: "AgentsAPI"): self._agents_api = agents_api @@ -286,11 +292,6 @@ def _raw(self) -> AuthenticatedClient: def _org_id(self) -> UUID: return UUID(str(self._agents_api.config.organization_id)) - @staticmethod - def _iter_chunks(items, chunk_size: int): - for i in range(0, len(items), chunk_size): - yield items[i : i + chunk_size] - def list( self, agent_id: str, @@ -349,7 +350,7 @@ def retrieve_result(self, job_id: str) -> AgentJobResultResponse: def retrieve_status_many(self, job_ids: list[str]) -> list[AgentJobStatus]: results: list[AgentJobStatus] = [] is_first_chunk = True - for chunk in self._iter_chunks(job_ids, self._MAX_BATCH_SIZE): + for chunk in _iter_chunks(job_ids, _MAX_BATCH_SIZE): if not is_first_chunk: time.sleep(self._agents_api.config.batch_chunk_delay) is_first_chunk = False @@ -372,7 +373,7 @@ def retrieve_result_many( ) -> list[Any]: # AgentJobResultItem results: list[Any] = [] is_first_chunk = True - for chunk in self._iter_chunks(job_ids, self._MAX_BATCH_SIZE): + for chunk in _iter_chunks(job_ids, _MAX_BATCH_SIZE): if not is_first_chunk: time.sleep(self._agents_api.config.batch_chunk_delay) is_first_chunk = False @@ -471,8 +472,6 @@ def delete_data(self, job_id: str) -> AgentJobDeleteDataResponse: class AgentsAPI: """API for managing and running agents.""" - _MAX_BATCH_SIZE = 1000 - def __init__(self, config: RoeConfig, raw_client: AuthenticatedClient): self.config = config self._raw = raw_client @@ -491,11 +490,6 @@ def versions(self) -> AgentVersionsAPI: def jobs(self) -> AgentJobsAPI: return self._jobs - @staticmethod - def _iter_chunks(items, chunk_size: int): - for i in range(0, len(items), chunk_size): - yield items[i : i + chunk_size] - def list( self, page: int | None = None, @@ -662,7 +656,7 @@ def run_many( """ all_job_ids: list[str] = [] is_first_chunk = True - for chunk in self._iter_chunks(batch_inputs, self._MAX_BATCH_SIZE): + for chunk in _iter_chunks(batch_inputs, _MAX_BATCH_SIZE): if not is_first_chunk: time.sleep(self.config.batch_chunk_delay) is_first_chunk = False From 3d3c7a08ad67315e52935fed05dd0bc02ebd7640 Mon Sep 17 00:00:00 2001 From: Jaden Fix Date: Thu, 8 Oct 2026 20:05:59 -0700 Subject: [PATCH 5/5] Use UNSET directly instead of the _UNSET_SENTINEL wrapper _UNSET_SENTINEL() in models/job.py only lazily imported and returned roe._generated.types.UNSET. The module already imports from roe._generated at the top, so import UNSET there and drop the wrapper. Tested: uv run pytest, ruff check, ruff format --check pass; manual check that JobBatch.retrieve_status still sets error_message to Unset for both fresh and cached statuses. --- src/roe/models/job.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/roe/models/job.py b/src/roe/models/job.py index 3d3fd80..a7ba97a 100644 --- a/src/roe/models/job.py +++ b/src/roe/models/job.py @@ -16,6 +16,7 @@ from roe._generated.models.agent_job_result_response import AgentJobResultResponse from roe._generated.models.agent_job_single_status import AgentJobSingleStatus from roe._generated.models.agent_job_status import AgentJobStatus +from roe._generated.types import UNSET from roe.exceptions import NotFoundError, RoeAPIException if TYPE_CHECKING: @@ -277,7 +278,7 @@ def retrieve_status(self) -> dict[str, AgentJobStatus]: timestamp=cached.get("timestamp", 0), error_message=cached["error_message"] if cached["error_message"] is not None - else _UNSET_SENTINEL(), + else UNSET, ) else: jobs_to_query.append(job_id) @@ -298,7 +299,7 @@ def retrieve_status(self) -> dict[str, AgentJobStatus]: created_at=None, last_updated_at=None, timestamp=self._extract_timestamp(status_item), - error_message=err if err is not None else _UNSET_SENTINEL(), + error_message=err if err is not None else UNSET, ) self._job_statuses[job_id] = { "status": stat_code, @@ -348,10 +349,3 @@ def _extract_timestamp(status_item: Any) -> int: if isinstance(value, Unset) or value is None: return 0 return int(value) - - -def _UNSET_SENTINEL(): # noqa: N802 — match generated naming style - """Return the ``Unset`` sentinel from the generated types module.""" - from roe._generated.types import UNSET - - return UNSET