Skip to content

Commit c244015

Browse files
committed
Document pydantic validation in the README
Functionality implemented in commit e2b654d Update readme to correct format for OrderedSet.__str__
1 parent cf305a7 commit c244015

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ A simple and efficient pure-python ordered set.
1111
```python
1212
from techcable.orderedset import OrderedSet
1313

14-
# prints "1, 2, 7, 3"
14+
# prints {1, 2, 7, 3}
1515
print(OrderedSet([1, 2, 7, 2, 3]))
1616
```
1717

18+
Supports [pydantic](pydantic.org) validation & serialization:
19+
```python
20+
import pydantic
21+
from techcable.orderedset import OrderedSet
22+
23+
model = pydantic.TypeAdapter(OrderedSet[int])
24+
# prints OrderedSet([1,2,7,8])
25+
print(repr(model.validate_python([1,2,7,8])))
26+
assert model.dump_python(OrderedSet([1,2,7,8])) == [1,2,7,8]
27+
```
28+
1829
## Potential Future Features
1930
- Add [acceleration module] using C/Rust/Cython
2031
- Implemented `OrderedFrozenSet`

0 commit comments

Comments
 (0)