Repository navigation
Fix Root Model Not Rendering As Expected - #1396
Conversation
|
@alexmojaki I was thinking of something like this for the problem discussed in #1108, where If this is the correct approach, how can I test it out locally if I register
|
from pydantic import RootModel
import logfire
logfire.configure(console=logfire.ConsoleOptions(verbose=True))
MyRootModel = RootModel[str]
r = MyRootModel('test')
logfire.info('MyRootModel', r1=r, r2=r.root)
# │ r1='"test"' # this is bad
# │ r2='test' |
|
@alexmojaki can you please check my changes thus far? Please provide pointers on how to deal with this. Meanwhile will try to fix this. |
|
No we only want to change the schema for strings that were inside RootModels since they get an extra layer of JSON encoding that we can't really avoid. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@alexmojaki I have made the required changes and updated description with Logfire dashboard screenshots, please check. edit: added |
from pydantic import RootModel
import logfire
logfire.configure(console=logfire.ConsoleOptions(verbose=True))
MyRootModel = RootModel[str]
r = MyRootModel('test')
logfire.info('MyRootModel', r1=r, r2=r.root)
# │ r1=test
# │ r2='test'I expect |
|
@alexmojaki how can I run PR-specific coverage locally? tried the command mentioned here but it runs for all the files |
|
I don't know of any way to get coverage without running everything |
|
Please add tests for the console exporter, the JSON formatting tests aren't actually very robust. |
|
@alexmojaki please validate whether the core logic is fine now, meanwhile I'll start looking into the console exporter tests. |
|
Add tests to |
This reverts commit 9d8419c.
- handle data conversion at formatting level for console
b80de2f to
c39a4ab
Compare
Done, added test for |
alexmojaki
left a comment
There was a problem hiding this comment.
Thanks for your patience!

This PR fixes #1107.
Brings over core logic introduced in #1108 PR with additional required changes to make schema non-trivial and ensure apt formatter parsing.
Logs for
RootModels encapsulating string literals: