waldiez 0.6.0__py3-none-any.whl → 0.6.1__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.

Potentially problematic release.


This version of waldiez might be problematic. Click here for more details.

Files changed (188) hide show
  1. waldiez/__init__.py +1 -1
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +18 -7
  4. waldiez/cli_extras/jupyter.py +3 -0
  5. waldiez/cli_extras/runner.py +3 -1
  6. waldiez/cli_extras/studio.py +3 -1
  7. waldiez/exporter.py +9 -3
  8. waldiez/exporting/agent/exporter.py +9 -10
  9. waldiez/exporting/agent/extras/captain_agent_extras.py +6 -6
  10. waldiez/exporting/agent/extras/doc_agent_extras.py +6 -6
  11. waldiez/exporting/agent/extras/group_manager_agent_extas.py +34 -23
  12. waldiez/exporting/agent/extras/group_member_extras.py +6 -5
  13. waldiez/exporting/agent/extras/handoffs/after_work.py +1 -1
  14. waldiez/exporting/agent/extras/handoffs/available.py +1 -1
  15. waldiez/exporting/agent/extras/handoffs/condition.py +3 -2
  16. waldiez/exporting/agent/extras/handoffs/handoff.py +1 -1
  17. waldiez/exporting/agent/extras/handoffs/target.py +6 -4
  18. waldiez/exporting/agent/extras/rag/chroma_extras.py +27 -19
  19. waldiez/exporting/agent/extras/rag/mongo_extras.py +8 -8
  20. waldiez/exporting/agent/extras/rag/pgvector_extras.py +5 -5
  21. waldiez/exporting/agent/extras/rag/qdrant_extras.py +5 -4
  22. waldiez/exporting/agent/extras/rag/vector_db_extras.py +1 -1
  23. waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +5 -7
  24. waldiez/exporting/agent/extras/reasoning_agent_extras.py +3 -5
  25. waldiez/exporting/chats/exporter.py +4 -4
  26. waldiez/exporting/chats/processor.py +1 -2
  27. waldiez/exporting/chats/utils/common.py +89 -48
  28. waldiez/exporting/chats/utils/group.py +9 -9
  29. waldiez/exporting/chats/utils/nested.py +7 -7
  30. waldiez/exporting/chats/utils/sequential.py +1 -1
  31. waldiez/exporting/chats/utils/single.py +2 -2
  32. waldiez/exporting/core/content.py +7 -7
  33. waldiez/exporting/core/context.py +5 -3
  34. waldiez/exporting/core/exporter.py +5 -3
  35. waldiez/exporting/core/exporters.py +2 -2
  36. waldiez/exporting/core/extras/agent_extras/captain_extras.py +2 -2
  37. waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +2 -2
  38. waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +2 -2
  39. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -8
  40. waldiez/exporting/core/extras/base.py +7 -5
  41. waldiez/exporting/core/extras/flow_extras.py +4 -5
  42. waldiez/exporting/core/extras/model_extras.py +2 -2
  43. waldiez/exporting/core/extras/path_resolver.py +1 -2
  44. waldiez/exporting/core/extras/serializer.py +2 -2
  45. waldiez/exporting/core/protocols.py +6 -5
  46. waldiez/exporting/core/result.py +25 -28
  47. waldiez/exporting/core/types.py +10 -10
  48. waldiez/exporting/core/utils/llm_config.py +2 -2
  49. waldiez/exporting/core/validation.py +10 -11
  50. waldiez/exporting/flow/execution_generator.py +98 -10
  51. waldiez/exporting/flow/exporter.py +2 -2
  52. waldiez/exporting/flow/factory.py +2 -2
  53. waldiez/exporting/flow/file_generator.py +4 -2
  54. waldiez/exporting/flow/merger.py +5 -3
  55. waldiez/exporting/flow/orchestrator.py +72 -2
  56. waldiez/exporting/flow/utils/common.py +5 -5
  57. waldiez/exporting/flow/utils/importing.py +6 -7
  58. waldiez/exporting/flow/utils/linting.py +25 -9
  59. waldiez/exporting/flow/utils/logging.py +2 -2
  60. waldiez/exporting/models/exporter.py +8 -8
  61. waldiez/exporting/models/processor.py +5 -5
  62. waldiez/exporting/tools/exporter.py +2 -2
  63. waldiez/exporting/tools/processor.py +7 -4
  64. waldiez/io/__init__.py +8 -4
  65. waldiez/io/_ws.py +10 -6
  66. waldiez/io/models/constants.py +10 -10
  67. waldiez/io/models/content/audio.py +1 -0
  68. waldiez/io/models/content/base.py +20 -18
  69. waldiez/io/models/content/file.py +1 -0
  70. waldiez/io/models/content/image.py +1 -0
  71. waldiez/io/models/content/text.py +1 -0
  72. waldiez/io/models/content/video.py +1 -0
  73. waldiez/io/models/user_input.py +10 -5
  74. waldiez/io/models/user_response.py +17 -16
  75. waldiez/io/mqtt.py +18 -31
  76. waldiez/io/redis.py +18 -22
  77. waldiez/io/structured.py +52 -53
  78. waldiez/io/utils.py +3 -0
  79. waldiez/io/ws.py +5 -1
  80. waldiez/logger.py +16 -3
  81. waldiez/models/agents/__init__.py +3 -0
  82. waldiez/models/agents/agent/agent.py +23 -16
  83. waldiez/models/agents/agent/agent_data.py +25 -22
  84. waldiez/models/agents/agent/code_execution.py +9 -11
  85. waldiez/models/agents/agent/termination_message.py +10 -12
  86. waldiez/models/agents/agent/update_system_message.py +2 -4
  87. waldiez/models/agents/agents.py +8 -8
  88. waldiez/models/agents/assistant/assistant.py +6 -3
  89. waldiez/models/agents/assistant/assistant_data.py +2 -2
  90. waldiez/models/agents/captain/captain_agent.py +7 -4
  91. waldiez/models/agents/captain/captain_agent_data.py +5 -7
  92. waldiez/models/agents/doc_agent/doc_agent.py +7 -4
  93. waldiez/models/agents/doc_agent/doc_agent_data.py +9 -10
  94. waldiez/models/agents/doc_agent/rag_query_engine.py +10 -12
  95. waldiez/models/agents/extra_requirements.py +3 -3
  96. waldiez/models/agents/group_manager/group_manager.py +12 -7
  97. waldiez/models/agents/group_manager/group_manager_data.py +13 -12
  98. waldiez/models/agents/group_manager/speakers.py +17 -19
  99. waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +7 -4
  100. waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +4 -1
  101. waldiez/models/agents/rag_user_proxy/retrieve_config.py +69 -63
  102. waldiez/models/agents/rag_user_proxy/vector_db_config.py +19 -19
  103. waldiez/models/agents/reasoning/reasoning_agent.py +7 -4
  104. waldiez/models/agents/reasoning/reasoning_agent_data.py +3 -2
  105. waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +8 -8
  106. waldiez/models/agents/user_proxy/user_proxy.py +6 -3
  107. waldiez/models/agents/user_proxy/user_proxy_data.py +1 -1
  108. waldiez/models/chat/chat.py +27 -20
  109. waldiez/models/chat/chat_data.py +22 -19
  110. waldiez/models/chat/chat_message.py +9 -9
  111. waldiez/models/chat/chat_nested.py +9 -9
  112. waldiez/models/chat/chat_summary.py +6 -6
  113. waldiez/models/common/__init__.py +2 -0
  114. waldiez/models/common/ag2_version.py +2 -0
  115. waldiez/models/common/dict_utils.py +8 -6
  116. waldiez/models/common/handoff.py +18 -17
  117. waldiez/models/common/method_utils.py +7 -7
  118. waldiez/models/common/naming.py +49 -0
  119. waldiez/models/flow/flow.py +11 -6
  120. waldiez/models/flow/flow_data.py +23 -17
  121. waldiez/models/flow/info.py +3 -3
  122. waldiez/models/flow/naming.py +2 -1
  123. waldiez/models/model/_aws.py +11 -13
  124. waldiez/models/model/_llm.py +5 -0
  125. waldiez/models/model/_price.py +2 -4
  126. waldiez/models/model/extra_requirements.py +1 -3
  127. waldiez/models/model/model.py +2 -2
  128. waldiez/models/model/model_data.py +21 -21
  129. waldiez/models/tool/extra_requirements.py +2 -4
  130. waldiez/models/tool/predefined/_duckduckgo.py +1 -0
  131. waldiez/models/tool/predefined/_email.py +1 -0
  132. waldiez/models/tool/predefined/_google.py +1 -0
  133. waldiez/models/tool/predefined/_perplexity.py +1 -0
  134. waldiez/models/tool/predefined/_searxng.py +1 -0
  135. waldiez/models/tool/predefined/_tavily.py +1 -0
  136. waldiez/models/tool/predefined/_wikipedia.py +1 -0
  137. waldiez/models/tool/predefined/_youtube.py +1 -0
  138. waldiez/models/tool/tool.py +8 -5
  139. waldiez/models/tool/tool_data.py +2 -2
  140. waldiez/models/waldiez.py +152 -4
  141. waldiez/runner.py +11 -5
  142. waldiez/running/async_utils.py +192 -0
  143. waldiez/running/base_runner.py +117 -264
  144. waldiez/running/dir_utils.py +52 -0
  145. waldiez/running/environment.py +10 -44
  146. waldiez/running/events_mixin.py +252 -0
  147. waldiez/running/exceptions.py +20 -0
  148. waldiez/running/gen_seq_diagram.py +18 -15
  149. waldiez/running/io_utils.py +216 -0
  150. waldiez/running/protocol.py +11 -5
  151. waldiez/running/requirements_mixin.py +65 -0
  152. waldiez/running/results_mixin.py +926 -0
  153. waldiez/running/standard_runner.py +22 -25
  154. waldiez/running/step_by_step/breakpoints_mixin.py +192 -60
  155. waldiez/running/step_by_step/command_handler.py +3 -0
  156. waldiez/running/step_by_step/events_processor.py +194 -14
  157. waldiez/running/step_by_step/step_by_step_models.py +110 -43
  158. waldiez/running/step_by_step/step_by_step_runner.py +107 -57
  159. waldiez/running/subprocess_runner/__base__.py +9 -1
  160. waldiez/running/subprocess_runner/_async_runner.py +5 -3
  161. waldiez/running/subprocess_runner/_sync_runner.py +6 -2
  162. waldiez/running/subprocess_runner/runner.py +39 -23
  163. waldiez/running/timeline_processor.py +1 -1
  164. waldiez/utils/__init__.py +2 -0
  165. waldiez/utils/conflict_checker.py +4 -4
  166. waldiez/utils/python_manager.py +415 -0
  167. waldiez/ws/_file_handler.py +18 -18
  168. waldiez/ws/_mock.py +2 -1
  169. waldiez/ws/cli.py +36 -12
  170. waldiez/ws/client_manager.py +35 -27
  171. waldiez/ws/errors.py +3 -0
  172. waldiez/ws/models.py +43 -52
  173. waldiez/ws/reloader.py +12 -4
  174. waldiez/ws/server.py +85 -55
  175. waldiez/ws/session_manager.py +8 -9
  176. waldiez/ws/session_stats.py +1 -1
  177. waldiez/ws/utils.py +4 -1
  178. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/METADATA +82 -93
  179. waldiez-0.6.1.dist-info/RECORD +254 -0
  180. waldiez/running/post_run.py +0 -186
  181. waldiez/running/pre_run.py +0 -281
  182. waldiez/running/run_results.py +0 -14
  183. waldiez/running/utils.py +0 -625
  184. waldiez-0.6.0.dist-info/RECORD +0 -251
  185. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/WHEEL +0 -0
  186. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/entry_points.txt +0 -0
  187. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/licenses/LICENSE +0 -0
  188. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/licenses/NOTICE.md +0 -0
@@ -3,7 +3,7 @@
3
3
  """Content module for Waldiez exporting core."""
4
4
 
5
5
  from dataclasses import dataclass, field
6
- from typing import Any, Optional
6
+ from typing import Any
7
7
 
8
8
  from .enums import (
9
9
  AgentPosition,
@@ -20,9 +20,9 @@ class PositionedContent:
20
20
  content: str
21
21
  position: ExportPosition
22
22
  order: int = 0
23
- agent_id: Optional[str] = None
24
- agent_position: Optional[AgentPosition] = None
25
- metadata: dict[str, Any] = field(default_factory=dict[str, Any])
23
+ agent_id: str | None = None
24
+ agent_position: AgentPosition | None = None
25
+ metadata: dict[str, Any] = field(default_factory=dict)
26
26
 
27
27
  def __post_init__(self) -> None:
28
28
  """Validate positioned content."""
@@ -64,6 +64,6 @@ class ContentMetadata:
64
64
  """Metadata about exported content."""
65
65
 
66
66
  content_type: ContentType
67
- source_id: Optional[str] = None
68
- dependencies: list[str] = field(default_factory=list[str])
69
- tags: set[str] = field(default_factory=set[str])
67
+ source_id: str | None = None
68
+ dependencies: list[str] = field(default_factory=list)
69
+ tags: set[str] = field(default_factory=set)
@@ -2,9 +2,11 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Singleton context for exporters."""
4
4
 
5
+ from __future__ import annotations
6
+
5
7
  import threading
6
8
  from dataclasses import dataclass
7
- from typing import Any, Optional
9
+ from typing import Any
8
10
 
9
11
  from waldiez.logger import WaldiezLogger, get_logger
10
12
 
@@ -137,10 +139,10 @@ class DefaultExporterContext(ExporterContext):
137
139
  Direct instantiation may not behave as expected.
138
140
  """
139
141
 
140
- _instance: Optional["DefaultExporterContext"] = None
142
+ _instance: DefaultExporterContext | None = None
141
143
  _lock = threading.Lock()
142
144
 
143
- def __new__(cls, *args: Any, **kwargs: Any) -> "DefaultExporterContext":
145
+ def __new__(cls, *args: Any, **kwargs: Any) -> DefaultExporterContext:
144
146
  """Create a new instance of DefaultExporterContext.
145
147
 
146
148
  Parameters
@@ -1,10 +1,12 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=too-few-public-methods
4
+ # pyright: reportUnusedParameter=false
5
+
4
6
  """Base exporter classes."""
5
7
 
6
8
  import abc
7
- from typing import Any, Generic, Optional
9
+ from typing import Any, Generic
8
10
 
9
11
  from .constants import DEFAULT_IMPORT_POSITION
10
12
  from .content import PositionedContent
@@ -30,7 +32,7 @@ class Exporter(abc.ABC, Generic[Extras]):
30
32
 
31
33
  def __init__(
32
34
  self,
33
- context: Optional[ExporterContext] = None,
35
+ context: ExporterContext | None = None,
34
36
  **kwargs: Any,
35
37
  ):
36
38
  """Initialize the exporter.
@@ -312,7 +314,7 @@ class Exporter(abc.ABC, Generic[Extras]):
312
314
  self._ensure_initialized()
313
315
  return self._result.get_content_by_position(position)
314
316
 
315
- def get_main_content(self) -> Optional[str]:
317
+ def get_main_content(self) -> str | None:
316
318
  """Get the main content.
317
319
 
318
320
  Returns
@@ -3,7 +3,7 @@
3
3
 
4
4
  """Exporters for Waldiez."""
5
5
 
6
- from typing import Any, Optional
6
+ from typing import Any
7
7
 
8
8
  from .exporter import Exporter
9
9
  from .types import Extras
@@ -50,7 +50,7 @@ class ConfigurableExporter(Exporter[Extras]):
50
50
  """
51
51
  raise NotImplementedError("Subclasses must implement this method.")
52
52
 
53
- def __init__(self, config: Optional[dict[str, Any]] = None, **kwargs: Any):
53
+ def __init__(self, config: dict[str, Any] | None = None, **kwargs: Any):
54
54
  """Initialize with configuration.
55
55
 
56
56
  Parameters
@@ -3,7 +3,7 @@
3
3
  """Captain agent extras module."""
4
4
 
5
5
  from dataclasses import dataclass
6
- from typing import Any, Optional
6
+ from typing import Any
7
7
 
8
8
  from waldiez.exporting.core.result import ExportResult
9
9
 
@@ -14,7 +14,7 @@ from .standard_extras import StandardExtras
14
14
  class CaptainExtras(StandardExtras):
15
15
  """Extras for captain agents."""
16
16
 
17
- nested_config: Optional[dict[str, Any]] = None
17
+ nested_config: dict[str, Any] | None = None
18
18
 
19
19
  def _contribute_specific_content(self, result: ExportResult) -> None:
20
20
  """Contribute captain specific content to the export result.
@@ -26,7 +26,7 @@ class GroupManagerExtras(StandardExtras):
26
26
  # Pattern-based content
27
27
  pattern_definition: str = ""
28
28
  pattern_class_name: str = "AutoPattern"
29
- pattern_imports: set[str] = field(default_factory=set[str])
29
+ pattern_imports: set[str] = field(default_factory=set)
30
30
 
31
31
  # Traditional GroupChat content
32
32
  group_chat_definition: str = ""
@@ -88,7 +88,7 @@ class GroupManagerExtras(StandardExtras):
88
88
  order=ContentOrder.LATE_CLEANUP,
89
89
  )
90
90
 
91
- # Add grop chat argument if specified
91
+ # Add group chat argument if specified
92
92
  if self.group_chat_argument:
93
93
  self.add_arg(self.group_chat_argument, tabs=1)
94
94
 
@@ -1,6 +1,6 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
- """RAG related extas."""
3
+ """RAG related extras."""
4
4
 
5
5
  from dataclasses import dataclass, field
6
6
 
@@ -15,7 +15,7 @@ class RAGUserExtras(StandardExtras):
15
15
  """RAG configuration."""
16
16
 
17
17
  before_content: str = ""
18
- imports: set[str] = field(default_factory=set[str])
18
+ imports: set[str] = field(default_factory=set)
19
19
 
20
20
  def _contribute_specific_content(self, result: ExportResult) -> None:
21
21
  """Contribute RAG specific content to the export result."""
@@ -4,7 +4,6 @@
4
4
  """Standard agent extras module."""
5
5
 
6
6
  from dataclasses import dataclass
7
- from typing import Optional
8
7
 
9
8
  from ...enums import AgentPosition, ExportPosition
10
9
  from ...result import ExportResult
@@ -76,9 +75,9 @@ class SystemMessageConfig:
76
75
  class StandardExtras(BaseExtras):
77
76
  """Extras for standard agents (UserProxy, Assistant, etc.)."""
78
77
 
79
- code_execution_config: Optional[CodeExecutionConfig] = None
80
- termination_config: Optional[TerminationConfig] = None
81
- system_message_config: Optional[SystemMessageConfig] = None
78
+ code_execution_config: CodeExecutionConfig | None = None
79
+ termination_config: TerminationConfig | None = None
80
+ system_message_config: SystemMessageConfig | None = None
82
81
 
83
82
  def set_code_execution(self, config: CodeExecutionConfig) -> None:
84
83
  """Set code execution configuration.
@@ -155,14 +154,10 @@ class StandardExtras(BaseExtras):
155
154
  argument = self.termination_config.termination_arg
156
155
  else:
157
156
  argument = "None"
158
- comment: str | None = None
159
- if argument == "None":
160
- comment = "pyright: ignore"
161
157
  return InstanceArgument(
162
158
  instance_id=self.instance_id,
163
159
  name="is_termination_msg",
164
160
  value=argument,
165
- comment=comment,
166
161
  tabs=1,
167
162
  )
168
163
 
@@ -1,11 +1,13 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
 
4
+ # pyright: reportUnnecessaryIsInstance=false, reportUnusedParameter=false
5
+
4
6
  """Base extras system for all exporters."""
5
7
 
6
8
  import abc
9
+ from collections.abc import Sequence
7
10
  from dataclasses import dataclass, field
8
- from typing import Sequence
9
11
 
10
12
  from ..enums import AgentPosition, ContentOrder, ExportPosition, ImportPosition
11
13
  from ..protocols import ExportContributor
@@ -14,18 +16,18 @@ from ..types import ImportStatement, InstanceArgument
14
16
 
15
17
 
16
18
  @dataclass
17
- class BaseExtras(ExportContributor):
19
+ class BaseExtras(ExportContributor, metaclass=abc.ABCMeta):
18
20
  """Base class for all exporter extras with export contribution."""
19
21
 
20
22
  instance_id: str
21
23
  extra_imports: list[ImportStatement] = field(
22
- default_factory=list[ImportStatement]
24
+ default_factory=list,
23
25
  )
24
26
  before_agent: str = ""
25
27
  after_agent: str = ""
26
28
  after_all_agents: str = ""
27
29
  extra_args: list[InstanceArgument] = field(
28
- default_factory=list[InstanceArgument]
30
+ default_factory=list,
29
31
  )
30
32
 
31
33
  def get_extra_args_content(self) -> str:
@@ -51,7 +53,7 @@ class BaseExtras(ExportContributor):
51
53
  if isinstance(arg, InstanceArgument):
52
54
  if arg not in self.extra_args:
53
55
  self.extra_args.append(arg)
54
- elif isinstance(arg, str) and arg.strip(): # pyright: ignore
56
+ elif isinstance(arg, str) and arg.strip():
55
57
  # If it's a string, create an InstanceArgument
56
58
  # split by '=' (it's an argument line)
57
59
  parts = arg.split("=", 1)
@@ -5,7 +5,6 @@
5
5
  """Flow specific extras module."""
6
6
 
7
7
  from dataclasses import dataclass, field
8
- from typing import Optional
9
8
 
10
9
  from waldiez.utils import get_waldiez_version
11
10
 
@@ -25,10 +24,10 @@ class FlowExtras(BaseExtras):
25
24
  version: str = field(default_factory=get_waldiez_version)
26
25
 
27
26
  # Sub-exporter results
28
- tools_result: Optional[ExportResult] = None
29
- models_result: Optional[ExportResult] = None
30
- agents_result: Optional[ExportResult] = None
31
- chats_result: Optional[ExportResult] = None
27
+ tools_result: ExportResult | None = None
28
+ models_result: ExportResult | None = None
29
+ agents_result: ExportResult | None = None
30
+ chats_result: ExportResult | None = None
32
31
 
33
32
  # Generated script parts
34
33
  header_content: str = ""
@@ -4,7 +4,7 @@
4
4
  """Agent specific extras module."""
5
5
 
6
6
  from dataclasses import dataclass
7
- from typing import Any, Optional
7
+ from typing import Any
8
8
 
9
9
  from waldiez.exporting.core.result import ExportResult
10
10
 
@@ -16,7 +16,7 @@ from .base import BaseExtras
16
16
  class ModelExtras(BaseExtras):
17
17
  """Extras for model exporters."""
18
18
 
19
- llm_config: Optional[dict[str, Any]] = None
19
+ llm_config: dict[str, Any] | None = None
20
20
  config_file_path: str = ""
21
21
 
22
22
  def set_llm_config(self, config: dict[str, Any]) -> None:
@@ -3,7 +3,6 @@
3
3
  """Default path resolver for Waldiez items."""
4
4
 
5
5
  from pathlib import Path
6
- from typing import Union
7
6
 
8
7
  from ..protocols import PathResolver
9
8
 
@@ -70,7 +69,7 @@ class DefaultPathResolver(PathResolver):
70
69
  return None
71
70
 
72
71
 
73
- def _get_raw_path_string(path: Union[str, Path]) -> str:
72
+ def _get_raw_path_string(path: str | Path) -> str:
74
73
  """Get the raw path string.
75
74
 
76
75
  Parameters
@@ -5,7 +5,7 @@
5
5
  """serializer for converting items to formatted strings."""
6
6
 
7
7
  import json
8
- from typing import Any, Optional
8
+ from typing import Any
9
9
 
10
10
  from ..protocols import Serializer
11
11
 
@@ -37,7 +37,7 @@ class DefaultSerializer(Serializer):
37
37
  def serialize_item(
38
38
  item: Any,
39
39
  tabs: int = 1,
40
- visited: Optional[set[int]] = None,
40
+ visited: set[int] | None = None,
41
41
  ) -> str:
42
42
  """Convert an item to a formatted string with given indentation.
43
43
 
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=too-few-public-methods
4
+ # pyright: reportReturnType=false
4
5
  """Core exporting protocols."""
5
6
 
6
7
  from typing import Any, Protocol, runtime_checkable
@@ -28,7 +29,7 @@ class ExportContributor(Protocol):
28
29
  class Validator(Protocol):
29
30
  """Protocol for validation components."""
30
31
 
31
- def validate(self, content: Any) -> ValidationResult: # pyright: ignore
32
+ def validate(self, content: Any) -> ValidationResult:
32
33
  """Validate content and return result.
33
34
 
34
35
  Parameters
@@ -47,7 +48,7 @@ class Validator(Protocol):
47
48
  class Serializer(Protocol):
48
49
  """Protocol for serialization components."""
49
50
 
50
- def serialize(self, obj: Any, **kwargs: Any) -> str: # pyright: ignore
51
+ def serialize(self, obj: Any, **kwargs: Any) -> str:
51
52
  """Serialize an object to string representation.
52
53
 
53
54
  Parameters
@@ -68,7 +69,7 @@ class Serializer(Protocol):
68
69
  class PathResolver(Protocol):
69
70
  """Protocol for resolving a path."""
70
71
 
71
- def resolve(self, path: str) -> str: # pyright: ignore
72
+ def resolve(self, path: str) -> str:
72
73
  """Resolve a path.
73
74
 
74
75
  Parameters
@@ -87,7 +88,7 @@ class PathResolver(Protocol):
87
88
  If the path cannot be resolved.
88
89
  """
89
90
 
90
- def is_local(self, path: str) -> bool: # pyright: ignore
91
+ def is_local(self, path: str) -> bool:
91
92
  """Check if the given path is a local path.
92
93
 
93
94
  Parameters
@@ -112,7 +113,7 @@ class ContentGenerator(Protocol):
112
113
  after_run: str,
113
114
  skip_logging: bool,
114
115
  **kwargs: Any,
115
- ) -> str: # pyright: ignore
116
+ ) -> str:
116
117
  """Generate content based on provided parameters.
117
118
 
118
119
  Parameters
@@ -4,7 +4,7 @@
4
4
  """Export result containers and related classes."""
5
5
 
6
6
  from dataclasses import dataclass, field
7
- from typing import Any, Optional, Union
7
+ from typing import Any
8
8
 
9
9
  from .constants import (
10
10
  DEFAULT_EXPORT_POSITION,
@@ -31,21 +31,21 @@ from .validation import ValidationResult
31
31
  class ExportResult:
32
32
  """Complete export result with all components."""
33
33
 
34
- main_content: Optional[str] = None
34
+ main_content: str | None = None
35
35
  imports: set[ImportStatement] = field(
36
- default_factory=set[ImportStatement],
36
+ default_factory=set,
37
37
  )
38
38
  positioned_content: list[PositionedContent] = field(
39
- default_factory=list[PositionedContent],
39
+ default_factory=list,
40
40
  )
41
41
  instance_arguments: list[InstanceArgument] = field(
42
- default_factory=list[InstanceArgument],
42
+ default_factory=list,
43
43
  )
44
44
  environment_variables: list[EnvironmentVariable] = field(
45
- default_factory=list[EnvironmentVariable]
45
+ default_factory=list
46
46
  )
47
- validation_result: Optional[ValidationResult] = None
48
- metadata: dict[str, Any] = field(default_factory=dict[str, Any])
47
+ validation_result: ValidationResult | None = None
48
+ metadata: dict[str, Any] = field(default_factory=dict)
49
49
 
50
50
  def add_import(
51
51
  self, statement: str, position: ImportPosition = DEFAULT_IMPORT_POSITION
@@ -69,12 +69,9 @@ class ExportResult:
69
69
 
70
70
  def add_imports(
71
71
  self,
72
- statements: Union[
73
- set[str],
74
- list[str],
75
- set[ImportStatement],
76
- list[ImportStatement],
77
- ],
72
+ statements: (
73
+ set[str] | list[str] | set[ImportStatement] | list[ImportStatement]
74
+ ),
78
75
  position: ImportPosition = DEFAULT_IMPORT_POSITION,
79
76
  ) -> None:
80
77
  """Add multiple import statements.
@@ -106,7 +103,7 @@ class ExportResult:
106
103
  value: Any,
107
104
  instance_id: str,
108
105
  tabs: int = 0,
109
- comment: Optional[str] = None,
106
+ comment: str | None = None,
110
107
  ) -> None:
111
108
  """Add an instance argument.
112
109
 
@@ -120,7 +117,7 @@ class ExportResult:
120
117
  The ID of the instance this argument belongs to.
121
118
  tabs : int, optional
122
119
  Number of tabs for indentation, by default 0
123
- comment : Optional[str], optional
120
+ comment : str | None, optional
124
121
  Optional comment for the argument, by default None
125
122
  """
126
123
  if name and value is not None: # pragma: no branch
@@ -142,7 +139,7 @@ class ExportResult:
142
139
 
143
140
  def add_instance_arguments(
144
141
  self,
145
- arguments: Union[list[InstanceArgument], set[InstanceArgument]],
142
+ arguments: list[InstanceArgument] | set[InstanceArgument],
146
143
  ) -> None:
147
144
  """Add multiple instance arguments.
148
145
 
@@ -217,9 +214,9 @@ class ExportResult:
217
214
  position: ExportPosition = DEFAULT_EXPORT_POSITION,
218
215
  order: ContentOrder | int = ContentOrder.MAIN_CONTENT,
219
216
  skip_strip: bool = False,
220
- agent_id: Optional[str] = None,
221
- agent_position: Optional[AgentPosition] = None,
222
- metadata: Optional[dict[str, Any]] = None,
217
+ agent_id: str | None = None,
218
+ agent_position: AgentPosition | None = None,
219
+ metadata: dict[str, Any] | None = None,
223
220
  ) -> None:
224
221
  """Add positioned content.
225
222
 
@@ -257,7 +254,7 @@ class ExportResult:
257
254
  self,
258
255
  name: str,
259
256
  value: str,
260
- description: Optional[str] = None,
257
+ description: str | None = None,
261
258
  required: bool = True,
262
259
  ) -> None:
263
260
  """Add environment variable.
@@ -268,7 +265,7 @@ class ExportResult:
268
265
  The name of the environment variable.
269
266
  value : str
270
267
  The value of the environment variable.
271
- description : Optional[str], optional
268
+ description : str | None, optional
272
269
  Description of the variable, by default None
273
270
  required : bool, optional
274
271
  Whether the variable is required, by default True
@@ -353,7 +350,7 @@ class ExportResult:
353
350
  return sorted(content)
354
351
 
355
352
  def get_agent_content(
356
- self, agent_id: str, agent_position: Optional[AgentPosition] = None
353
+ self, agent_id: str, agent_position: AgentPosition | None = None
357
354
  ) -> list[PositionedContent]:
358
355
  """Get content positioned relative to a specific agent.
359
356
 
@@ -561,8 +558,8 @@ class ExportResultBuilder:
561
558
  content: str,
562
559
  position: ExportPosition = DEFAULT_EXPORT_POSITION,
563
560
  order: ContentOrder = ContentOrder.MAIN_CONTENT,
564
- agent_id: Optional[str] = None,
565
- agent_position: Optional[AgentPosition] = None,
561
+ agent_id: str | None = None,
562
+ agent_position: AgentPosition | None = None,
566
563
  ) -> "ExportResultBuilder":
567
564
  """Add positioned content.
568
565
 
@@ -574,7 +571,7 @@ class ExportResultBuilder:
574
571
  The content position, by default AGENTS
575
572
  order : int, optional
576
573
  The order within position, by default 0
577
- agent_id : Optional[str], optional
574
+ agent_id : str | None, optional
578
575
  Agent ID for agent-relative positioning, by default None
579
576
  agent_position : Optional[AgentPosition], optional
580
577
  Position relative to agent, by default None
@@ -594,7 +591,7 @@ class ExportResultBuilder:
594
591
  return self
595
592
 
596
593
  def with_env_var(
597
- self, name: str, value: str, description: Optional[str] = None
594
+ self, name: str, value: str, description: str | None = None
598
595
  ) -> "ExportResultBuilder":
599
596
  """Add environment variable.
600
597
 
@@ -604,7 +601,7 @@ class ExportResultBuilder:
604
601
  Variable name.
605
602
  value : str
606
603
  Variable value.
607
- description : Optional[str], optional
604
+ description : str | None, optional
608
605
  Variable description, by default None
609
606
 
610
607
  Returns
@@ -5,7 +5,7 @@
5
5
 
6
6
  from dataclasses import dataclass, field, fields
7
7
  from pathlib import Path
8
- from typing import Any, Optional, TypeVar
8
+ from typing import Any, TypeVar
9
9
 
10
10
  from .enums import (
11
11
  ImportPosition,
@@ -25,7 +25,7 @@ class _NoExtrasType:
25
25
  return "<NoExtras>"
26
26
 
27
27
 
28
- NoExtras = _NoExtrasType()
28
+ NoExtras = _NoExtrasType() # pylint: disable=invalid-name
29
29
 
30
30
 
31
31
  # Core Data Structures
@@ -35,7 +35,7 @@ class ImportStatement:
35
35
 
36
36
  statement: str
37
37
  position: ImportPosition = ImportPosition.THIRD_PARTY
38
- metadata: Optional[dict[str, Any]] = None
38
+ metadata: dict[str, Any] | None = None
39
39
 
40
40
  def __hash__(self) -> int:
41
41
  """Hash based on the import statement.
@@ -89,7 +89,7 @@ class EnvironmentVariable:
89
89
 
90
90
  name: str
91
91
  value: str
92
- description: Optional[str] = None
92
+ description: str | None = None
93
93
  required: bool = True
94
94
 
95
95
  def __post_init__(self) -> None:
@@ -151,7 +151,7 @@ class InstanceArgument:
151
151
  with_new_line_if_empty: bool = False
152
152
  skip_if_empty_string: bool = True
153
153
  skip_trailing_comma: bool = False
154
- comment: Optional[str] = None
154
+ comment: str | None = None
155
155
 
156
156
  def has_content(self) -> bool:
157
157
  """Check if the instance argument has content.
@@ -266,13 +266,13 @@ class ExportConfig:
266
266
  description: str = (
267
267
  "Make AG2 Agents Collaborate: Drag, Drop, and Orchestrate with Waldiez"
268
268
  )
269
- requirements: list[str] = field(default_factory=list[str])
270
- tags: list[str] = field(default_factory=list[str])
269
+ requirements: list[str] = field(default_factory=list)
270
+ tags: list[str] = field(default_factory=list)
271
271
  output_extension: str = "py"
272
272
  is_async: bool = False
273
- output_directory: Optional[str | Path] = None
274
- uploads_root: Optional[Path] = None
275
- cache_seed: Optional[int] = None
273
+ output_directory: str | Path | None = None
274
+ uploads_root: Path | None = None
275
+ cache_seed: int | None = None
276
276
 
277
277
  @property
278
278
  def for_notebook(self) -> bool:
@@ -64,7 +64,7 @@ def _get_agent_llm_config_arg_as_arg(
64
64
  tab = " " * tab_leng * tabs if tabs > 0 else ""
65
65
  # tab = " " * tabs if tabs > 0 else ""
66
66
  if not agent.data.model_ids:
67
- return f"{tab}llm_config=False, # pyright: ignore" + "\n"
67
+ return f"{tab}llm_config=False," + "\n"
68
68
  content = f"{tab}llm_config=autogen.LLMConfig(" + "\n"
69
69
  content += f"{tab} config_list=["
70
70
  got_at_least_one_model = False
@@ -77,7 +77,7 @@ def _get_agent_llm_config_arg_as_arg(
77
77
  content += "\n" + f"{tab} {model_name}_llm_config,"
78
78
  got_at_least_one_model = True
79
79
  if not got_at_least_one_model: # pragma: no cover
80
- return f"{tab}llm_config=False, # pyright: ignore" + "\n"
80
+ return f"{tab}llm_config=False," + "\n"
81
81
  content += "\n" + f"{tab} ]," + "\n"
82
82
  content += f"{tab} cache_seed={cache_seed}," + "\n"
83
83
  if temperature is not None: