python-codex 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,19 +123,23 @@ def load_workspace_definitions(
123
123
  )
124
124
 
125
125
  board_value = item.get("board")
126
- if not str(board_value or "").strip():
127
- raise ValueError("workspace `{0}` is missing `board`".format(workspace_id))
128
- board_path = _resolve_workspace_path(str(board_value), path.parent)
129
- if board_path in seen_boards:
130
- raise ValueError("duplicate workspace board: {0}".format(board_path))
131
- seen_boards.add(board_path)
132
- if not board_path.parent.is_dir():
133
- raise ValueError(
134
- "workspace `{0}` board parent directory does not exist: {1}".format(
135
- workspace_id,
136
- board_path.parent,
126
+ board_path = None
127
+ if board_value is not False:
128
+ if not isinstance(board_value, str) or not board_value.strip():
129
+ raise ValueError(
130
+ "workspace `{0}` requires a board path or false".format(workspace_id)
131
+ )
132
+ board_path = _resolve_workspace_path(board_value, path.parent)
133
+ if board_path in seen_boards:
134
+ raise ValueError("duplicate workspace board: {0}".format(board_path))
135
+ seen_boards.add(board_path)
136
+ if not board_path.parent.is_dir():
137
+ raise ValueError(
138
+ "workspace `{0}` board parent directory does not exist: {1}".format(
139
+ workspace_id,
140
+ board_path.parent,
141
+ )
137
142
  )
138
- )
139
143
 
140
144
  result.append(
141
145
  WorkspaceDefinition(
@@ -169,7 +173,7 @@ def save_workspace_definitions(
169
173
  def _workspace_definition_to_json(
170
174
  definition: 'WorkspaceDefinition',
171
175
  base_dir: 'Path',
172
- ) -> 'typing.Dict[str, str]':
176
+ ) -> 'typing.Dict[str, object]':
173
177
  result = {
174
178
  "id": definition.workspace_id,
175
179
  "work_dir": _format_path_for_workspace_config(definition.work_dir, base_dir),
@@ -179,6 +183,8 @@ def _workspace_definition_to_json(
179
183
  definition.board_path,
180
184
  base_dir,
181
185
  )
186
+ else:
187
+ result["board"] = False
182
188
  return result
183
189
 
184
190
 
@@ -440,7 +446,7 @@ class WorkspaceRegistry:
440
446
 
441
447
  def _key_for_definition(self, definition: 'WorkspaceDefinition') -> str:
442
448
  if definition.board_path is None:
443
- raise ValueError("workspace `{0}` is missing board".format(definition.workspace_id))
449
+ return "workspace:{0}".format(definition.workspace_id)
444
450
  return str(definition.board_path.resolve())
445
451
 
446
452
  async def start(self) -> None:
@@ -466,7 +472,7 @@ class WorkspaceRegistry:
466
472
  self,
467
473
  name: str,
468
474
  work_dir: str = "./",
469
- board: "typing.Union[str, None]" = None,
475
+ board: "typing.Union[str, bool, None]" = None,
470
476
  ) -> 'WorkspaceEntry':
471
477
  if self._entry_factory is None:
472
478
  raise ValueError("workspace creation is unavailable")
@@ -475,15 +481,19 @@ class WorkspaceRegistry:
475
481
  resolved_work_dir = _resolve_workspace_path(str(work_dir or "./"), base_dir)
476
482
  resolved_work_dir.mkdir(parents=True, exist_ok=True)
477
483
 
478
- board_path = (
479
- _resolve_workspace_path(str(board), base_dir)
480
- if str(board or "").strip()
481
- else default_board_path()
482
- )
483
- board_path.parent.mkdir(parents=True, exist_ok=True)
484
- board_key = str(board_path.resolve())
485
- if board_key in self._entries:
486
- raise ValueError("workspace board already exists: {0}".format(board_path))
484
+ board_path = None
485
+ if board is not False:
486
+ if board is not None and not isinstance(board, str):
487
+ raise ValueError("board must be a path string or false")
488
+ board_path = (
489
+ _resolve_workspace_path(board, base_dir)
490
+ if board and board.strip()
491
+ else default_board_path()
492
+ )
493
+ board_path.parent.mkdir(parents=True, exist_ok=True)
494
+ board_key = str(board_path.resolve())
495
+ if board_key in self._entries:
496
+ raise ValueError("workspace board already exists: {0}".format(board_path))
487
497
 
488
498
  workspace_id = normalize_workspace_id(name)
489
499
  if not workspace_id: