trodo-python 2.19.0__py3-none-any.whl → 2.20.0__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.
trodo/__init__.py CHANGED
@@ -41,7 +41,7 @@ Downstream microservice (join the caller's run instead of making a new one):
41
41
 
42
42
  from __future__ import annotations
43
43
 
44
- __version__ = "2.19.0"
44
+ __version__ = "2.20.0"
45
45
 
46
46
  from typing import Any, Callable, Dict, List, Optional, Union
47
47
 
@@ -56,10 +56,12 @@ def _to_variables(raw: Any) -> List[PromptVariable]:
56
56
  out.append(v)
57
57
  elif isinstance(v, dict) and isinstance(v.get("name"), str):
58
58
  out.append(
59
+ # Named fields only — a stored version may carry keys this SDK
60
+ # no longer models (`required`, retired in 2.20.0), and fetching
61
+ # one must never raise.
59
62
  PromptVariable(
60
63
  name=v["name"],
61
64
  type=v.get("type") or "string",
62
- required=bool(v.get("required")),
63
65
  default=v.get("default"),
64
66
  description=v.get("description"),
65
67
  )
trodo/prompts/compile.py CHANGED
@@ -74,12 +74,10 @@ def build_scope(
74
74
  ) -> Dict[str, Any]:
75
75
  """Build the render scope from declarations + caller values.
76
76
 
77
- Resolution order: caller value -> declared default -> required-and-absent
78
- raises -> optional-and-absent renders empty.
77
+ Resolution order: caller value -> declared default -> empty.
79
78
 
80
- `required` is enforced HERE, in your process, before the model call -- Trodo
81
- only stores the declaration. A variable with a default can never fail this
82
- check, because the default is itself a value.
79
+ A missing value never raises. The one thing this does reject is a value for
80
+ a variable the prompt does not declare, which is almost always a typo.
83
81
  """
84
82
  errors: List[str] = []
85
83
  scope: Dict[str, Any] = {}
@@ -104,24 +102,13 @@ def build_scope(
104
102
  has = name in values
105
103
  value = values.get(name) if has else None
106
104
 
107
- # `required` asks a narrower question than default-substitution does:
108
- # did the caller supply something that will actually render? None and ""
109
- # both render as nothing, the very outcome the flag exists to prevent,
110
- # so neither counts. (0 and False do -- they render.)
111
- supplied = has and value is not None and value != ""
112
-
113
- # Missing value -> the declared default, or empty.
105
+ # A missing value resolves, it never fails: the declared default, or
106
+ # empty. That IS the point of declaring a default -- there is no third
107
+ # case where the caller has to have supplied something, and adding one
108
+ # would turn an empty render into a crash for no gain.
114
109
  if not has or value is None:
115
110
  value = default if has_default else ([] if type_ == "messages" else "")
116
111
 
117
- # A default always satisfies the requirement, so the two never both
118
- # apply; the editor won't let you author both, but a hand-written
119
- # declaration can.
120
- required = v.get("required") if isinstance(v, dict) else getattr(v, "required", None)
121
- if not supplied and required is True and not has_default:
122
- errors.append(f"variable '{name}': required, but no value was provided")
123
- continue
124
-
125
112
  scope[name] = _coerce(value, type_, name, errors)
126
113
 
127
114
  # Passing something the prompt doesn't declare is nearly always a rename
trodo/prompts/types.py CHANGED
@@ -26,24 +26,18 @@ class PromptVariable:
26
26
  """A declared variable.
27
27
 
28
28
  Every competitor leaves variables undeclared and untyped — discovered by
29
- regex, with no defaults and no required-ness. The declaration is what lets
30
- ``compile()`` fail before the model call rather than shipping a literal
31
- ``{{typo}}`` and finding out from the bill.
32
-
33
- ``required`` is enforced by ``compile()``, which runs in YOUR process
34
- Trodo only stores the declaration. Nothing server-side rejects a call for a
35
- missing variable, and nothing rejects a version for declaring one.
36
-
37
- Marking a variable required means the caller must pass a value that will
38
- actually render: an omitted key, ``None`` and ``""`` all fail, since all
39
- three render as nothing (``0`` and ``False`` pass). A variable with
40
- a ``default`` can never fail the check — the default is a value — so the two
41
- are mutually exclusive in practice.
29
+ regex, and with no defaults. Knowing the declared set is what lets
30
+ ``compile()`` catch a value passed for a variable that doesn't exist,
31
+ instead of silently rendering the wrong prompt.
32
+
33
+ A missing value never fails. It resolves to the declared ``default``, or to
34
+ empty that is what declaring a default is FOR. There is deliberately no
35
+ ``required`` flag: it would give the author a decision to get wrong and the
36
+ caller a crash where an empty render would do.
42
37
  """
43
38
 
44
39
  name: str
45
40
  type: str = "string"
46
- required: bool = False
47
41
  default: Any = None
48
42
  description: Optional[str] = None
49
43
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trodo-python
3
- Version: 2.19.0
3
+ Version: 2.20.0
4
4
  Summary: Trodo Analytics SDK for Python — server-side event tracking
5
5
  License: ISC
6
6
  Keywords: analytics,tracking,trodo,server-side
@@ -1,4 +1,4 @@
1
- trodo/__init__.py,sha256=n7YUScfJqdXfIUwWL-g1PekBrYfQ0A0m4kAme26rwUM,26928
1
+ trodo/__init__.py,sha256=ueM-l4KXHdP42DzvCRN9Zc5d4OsCxOSjiT-NIGAiLyQ,26928
2
2
  trodo/client.py,sha256=9UYaHZtWPMYdlG2xWVf77PQJ9DfFgN-zobTh60i8_Cc,22453
3
3
  trodo/types.py,sha256=eySgUvCXROG2TxtxgiU0MNr5iH0DEcduK8bmYtTKG44,3138
4
4
  trodo/user_context.py,sha256=uHCI2WYoOI3cNwdIUEuZdX4VYSu14pzm348ksn6hn_c,8195
@@ -13,7 +13,7 @@ trodo/managers/dataset_manager.py,sha256=gx0S8ujG3cbw4IskBNMdceBjDbcEh_nebwKSzEv
13
13
  trodo/managers/experiment_manager.py,sha256=V-vemLtenfSI5VIcP0HPiXzEy8AyTrRrbJVCA9Z6wjo,10579
14
14
  trodo/managers/group_manager.py,sha256=ki3Se3qEoSZfREX63oeDeBmEfZF-ISHLE8azEtLg0tM,3542
15
15
  trodo/managers/people_manager.py,sha256=mMVnx40Mlifx6NGgChvohC9ViK6dQu2mkXNHbV8pK1E,2882
16
- trodo/managers/prompt_manager.py,sha256=jFHkdvDSxvvb9c53EQvBQygdDJ7X-ylNWEY_ag_SeC0,11227
16
+ trodo/managers/prompt_manager.py,sha256=4xj_38b2qU31aTs5fIq-wNJnPisqf1zre0u8jvjZOF4,11375
17
17
  trodo/managers/user_manager.py,sha256=faJYX3CHrD7ulYiShV7FhThSMX9aJ3kdOgU4Qtdy5FM,2844
18
18
  trodo/otel/__init__.py,sha256=yiRFXWUU45bAM2CV37XeO7zf1hmnmjufdP4XO50yEyE,624
19
19
  trodo/otel/auto_instrument.py,sha256=Iae9A9lvh2PImE6gqnyEMXeRPRpjTxZcxx1zW2KDLac,21467
@@ -25,9 +25,9 @@ trodo/otel/register.py,sha256=bV_ePTfUvPugig2GZnylhzxi2QfoPWs96A9mGLPMrSQ,9387
25
25
  trodo/otel/transport.py,sha256=hzZz8gwSMGJ8CxdijmLn1Ljt18owr9XTWy13DLbwYbw,2441
26
26
  trodo/otel/wrap_agent.py,sha256=cJjrzlZNW2g6q_coLN7UR4uxn65h4u3-LNzMfE4dLVw,40999
27
27
  trodo/prompts/__init__.py,sha256=yunNc8WkTSfEEkRR-NZWXAt_ZB3Ee2INRh-4RE7uHj4,806
28
- trodo/prompts/compile.py,sha256=ydJDI7YS3PiLzAJ4H-kmqGV-1kkUxlQrf_xtZZ7fR5g,7267
28
+ trodo/prompts/compile.py,sha256=UhJhu-BtVicaauDEKpAXB17KhgVs4jWos_I60I8kZFk,6583
29
29
  trodo/prompts/template.py,sha256=obQiivPCR6LEdz7q1cby7uL25tYHYui4aoEaiUNqWfs,9357
30
- trodo/prompts/types.py,sha256=1TVGHp3vtWV1tr0l-IJfL7EKvrB8ZmQRwLvDqvbOfJ0,5007
30
+ trodo/prompts/types.py,sha256=A24njy6qcc8QNzWEfGu28BbBr360S7A5Pw7_ObIWNS4,4684
31
31
  trodo/queue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  trodo/queue/batch_flusher.py,sha256=4Lg6T3Urwi9U0Q4FpFGPmjDYKg4ZliCTR-ND8BJvWaY,1298
33
33
  trodo/queue/event_queue.py,sha256=EVFZrhlq_kwC3jJ2GK0wMhHISf9UzLCZNDnT_aZ2I2A,872
@@ -36,7 +36,7 @@ trodo/session/server_session.py,sha256=McsudEiq33XDq3nqxgzBcUvIjQxCMscwEuAPnYXrT
36
36
  trodo/session/session_manager.py,sha256=7ht5LeeZX1HLLfPeNV_a8NkXGbHl3up0CRtCGr3EzjQ,2995
37
37
  trodo/util/__init__.py,sha256=Z9c4rPPdKg06Kk3byKheDqksSgR4WNvS475oQ5sNljc,54
38
38
  trodo/util/lru.py,sha256=QIsM7s6J_E9ZjiXatSyReZIEeGypTAcgrPWWy8YsRa4,2465
39
- trodo_python-2.19.0.dist-info/METADATA,sha256=RD_p3hblnxk6pAacML6IkqzfdIqP33lD50GS1kApkW8,25308
40
- trodo_python-2.19.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
41
- trodo_python-2.19.0.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
42
- trodo_python-2.19.0.dist-info/RECORD,,
39
+ trodo_python-2.20.0.dist-info/METADATA,sha256=EYdoY1cwgukIxmryCG6QadL0qiIz5J8harU3y7v6Q0Y,25308
40
+ trodo_python-2.20.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
41
+ trodo_python-2.20.0.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
42
+ trodo_python-2.20.0.dist-info/RECORD,,