From b8a43e43902dcd76a3867538953257ff4c808c67 Mon Sep 17 00:00:00 2001 From: Nathaniel Starkman Date: Mon, 7 Oct 2024 10:09:31 -0400 Subject: [PATCH] Update README.md (#27) Signed-off-by: Nathaniel Starkman --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcc20f2..9eaa750 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

dataclassish

-

Tools from dataclasses, extended to all of Python

+

Tools from dataclasses, extended to all of Python

Python's [`dataclasses`][dataclasses-link] provides tools for working with objects, but only compatible `@dataclass` objects. 😢
This repository is a @@ -237,13 +237,14 @@ from dataclassish.converters import Optional, Unless @define class Class1: attr: int | None = field(default=None, converter=Optional(int)) + """attr is converted to an int or kept as None.""" obj = Class1() print(obj.attr) # None -obj = Class1(a=1) +obj = Class1(a=1.0) print(obj.attr) # 1 @@ -251,6 +252,7 @@ print(obj.attr) @define class Class2: attr: float | int = field(converter=Unless(int, converter=float)) + """attr is converted to a float, unless it's an int.""" obj = Class2(1)