From 77ecd538c9bde78268e9933b1634126b5c56a49f Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Mon, 4 Mar 2024 07:10:25 +0000 Subject: [PATCH] 0.1.2: implement __repr__ for ModelBoundTOML + bump --- README.md | 2 +- pyproject.toml | 2 +- test.py | 2 ++ tomlantic/__pycache__/__init__.cpython-38.pyc | Bin 1829 -> 1944 bytes .../__pycache__/tomlantic.cpython-38.pyc | Bin 9107 -> 11654 bytes tomlantic/tomlantic.py | 5 +++++ 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae0e103..b2712a5 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/pyproject.toml b/pyproject.toml index fae18ea..ada23ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "Unlicense" diff --git a/test.py b/test.py index 9ea6c2a..107b5d0 100644 --- a/test.py +++ b/test.py @@ -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 diff --git a/tomlantic/__pycache__/__init__.cpython-38.pyc b/tomlantic/__pycache__/__init__.cpython-38.pyc index 45a2c8c355e7198919687d5f4ebd889f3a095415..6055f01f57159cbf290e77c80ab0d52c3ba53b32 100644 GIT binary patch delta 189 zcmZ3=H-n!yl$V!_0SH`nK2AL|kyn<{VWPIKKrUAlS1xxHcP>v9PcCm1@5YE4Rz{x5 zS6Nk~g+ly&eH=?liZYW*OHy5nit>wY34_F(5{pxVGxO4Opo07$LARp(s?8u*96ql*E$E{JhC*Y?B!ICeLKEku3r_s)!pz@PG(jAhD96NC3nZn0$}T F9RRQfISc>* delta 73 zcmbQizm$(Rl$V!_0SIP)x}Q2}BCjl?!9;D{jTtqpj2x4nva0e3g!udV_+}OtXXd3( bPGy_K$Tj%~n+@kmh9VxIt|Fevf$Z)83QiQ* diff --git a/tomlantic/__pycache__/tomlantic.cpython-38.pyc b/tomlantic/__pycache__/tomlantic.cpython-38.pyc index 67515bb74d46ba7a66e7fa24e1a8bda3bc9378ae..0739d26b4513fd908bec25fa6192bc580632cbba 100644 GIT binary patch delta 4656 zcma(UNo*U}b^dTT+!s+IC0W~8c5E|o7&l(hcu^A9TVh*jy(Uc3@tFTh8fiEq{~0+k zLxX{3#234;Gnb&X0SWEJ?IA#f0zLK8qA1#;hoYxJ3*^w88Z0kXL7{h>(7v5S)U zkAHdZ{rBE~8~vm2zmYwg$s{HC9C1Ho>aIK4VRHMzQh%o~>rZ zI%?(W`D$LwRja37s20RL2J_x(pP0vCUaS_0#F8|zNUA0HO~P+KQ&@tP1|?Rask;%H zrkU$XbpUqbu-`u@(d?8Ar~R~r$2ppZ&7}a2{iS;DV zAXjz-vhMK_BobisgY>B<2XHxvU;_d~4wPBPwD~Zu*I@h2^gdEv`BnOyd>mPqRW67X z#6u22g4qjo#tn~kncY`-N6a8%(sw|J%j?*_o|_=MS3b=BhU|F~Sv`edJAw*=XAtZF z&?s)z>I<%?IX2UrDb2ew&s=RA*Zey@`^PpS+Bkwu2-e7r%PszAJ;(NLg=snVkktG; zh|p1()Y<^ zS>fTX|EJ!ORtF(a3_k6G_XxvuC4LErKZN0`03=ltuf1j10jY0hY&@Wa6imG zfZ=8VB*BDv5|1W{Oyn>5etaUxDjCS|`FQlD}Ns*(#t6FL@p}FD`g(SGtkZ;PVJs z?DmD!f$)Nd(bzkXakirXrmGn?tUV6G390bhv^8&rX?2G(3(l!v+})Wmj=S2F!!MeY zg05?*U4i*O6gm#d{Bn&#QGUD~9|>~Mzg6n@KP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311..90aedfa 100644 --- a/tomlantic/tomlantic.py +++ b/tomlantic/tomlantic.py @@ -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],