From 800e7deb654127793e16d730e6ba7da31b47720d Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Wed, 11 Nov 2026 19:46:24 -0700 Subject: [PATCH] Say that an empty value of another type still means no value The README and the constructor docstring said any non-string base_url, application, version, key or install_id raises a ValueError naming the argument. An empty one (0, False, []) does not: it keeps its old meaning, as test_an_empty_value_of_another_type_keeps_its_old_meaning pins down. Co-Authored-By: Claude Opus 5.5 --- README.md | 5 ++++- trace_client/trace_client.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85f65f0..f27bcfc 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,10 @@ required: a missing or blank one, one over 255 characters after trimming, or one that is not a string, raises `ValueError`. So does a value that is not a string for `base_url`, `application`, `key` or `install_id=`, naming the argument, whether or not the client ends up enabled, so a settings file that -turns `version: 1.4` into a number is caught at startup. Every event the +turns `version: 1.4` into a number is caught at startup. An empty value of +another type (`0`, `False`, `[]`) is taken as no value, as it was before +that check: no key, no installation ID, or `" is required"` for the +three positional arguments. Every event the client sends — `startup`, `command`, anything else — carries it as the tag `version`, so every event can be tied to a release, not just `startup`. An event that passes its own `version` tag diff --git a/trace_client/trace_client.py b/trace_client/trace_client.py index f1db2b3..8854a7e 100644 --- a/trace_client/trace_client.py +++ b/trace_client/trace_client.py @@ -161,7 +161,9 @@ def __init__(self, base_url: str, application: str, version: str, *, key: Option A value that is not a string for ``base_url``, ``application``, ``version``, ``key`` or ``install_id`` is a :class:`ValueError` naming the argument, even on a client that would be disabled: a settings - file that reads ``version: 1.4`` as a number should say so.""" + file that reads ``version: 1.4`` as a number should say so. An empty + one (``0``, ``False``, ``[]``) still means no value, as it did before + that check: no key, no ID, or " is required".""" for argument, given in (("base_url", base_url), ("application", application), ("version", version), ("key", key), ("install_id", install_id)): if given and not isinstance(given, str):