Skip to content

Commit

Permalink
0.1.2: implement __repr__ for ModelBoundTOML + bump
Browse files Browse the repository at this point in the history
  • Loading branch information
markjoshwel committed Mar 4, 2024
1 parent fe6f27e commit 77ecd53
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# tomlantic

> [!WARNING]
> tomlantic is at 0.1.1 and currently, only i use it myself. it isn't battle tested,
> tomlantic is at 0.1.2 and currently, only i use it myself. it isn't battle tested,
> so issues may arise.
> if you're willing to run into potential bugs and issues, feel free to use it!
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tomlantic"
version = "0.1.1"
version = "0.1.2"
description = "marrying pydantic models and tomlkit documents"
authors = ["Mark Joshwel <mark@joshwel.co>"]
license = "Unlicense"
Expand Down
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class File(pydantic.BaseModel):
# where tomlantic becomes handy
toml = ModelBoundTOML(File, toml_doc)

print(toml)

# access the model with .model and change the model freely
model: File = toml.model
model.project.typechecked = True
Expand Down
Binary file modified tomlantic/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified tomlantic/__pycache__/tomlantic.cpython-38.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions tomlantic/tomlantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ class ModelBoundTOML(Generic[M]):
__original_model: M
__document: TOMLDocument


def __repr__(self) -> str:
return f"{self.__class__.__name__}(model={self.model.__repr__()})"


def __init__(
self,
model: Type[M],
Expand Down

0 comments on commit 77ecd53

Please sign in to comment.