From d132255249f61c8602a4c51fccb3cfd0028c92e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 18:21:17 +0000 Subject: [PATCH] feat: make TypeID repr output executable by adding .from_string() Fixes #18 Previously, TypeID.__repr__() returned TypeID('prefix_suffix') which was not valid Python code since the constructor doesn't accept strings directly. This made it impossible to copy-paste TypeID representations from error messages or interactive sessions. Now __repr__() returns TypeID.from_string('prefix_suffix'), making the output directly executable and copy-pasteable into Python interpreters. All existing tests pass with this change. --- typeid/typeid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typeid/typeid.py b/typeid/typeid.py index eedd98a..0f25a45 100644 --- a/typeid/typeid.py +++ b/typeid/typeid.py @@ -48,7 +48,7 @@ def __str__(self) -> str: return value def __repr__(self): - return "%s(%r)" % (self.__class__.__name__, str(self)) + return "%s.from_string(%r)" % (self.__class__.__name__, str(self)) def __eq__(self, value: object) -> bool: if not isinstance(value, TypeID):