|
|
|
|
|
by Mehdi2277
1845 days ago
|
|
One of the pycon type talks was about type checking json. TypedDict or pydantic can both be used to deal with that fairly well now. For a complex json sure the type might be long but write it once and used the typeddict name after that. It feels similar to needing to write protobut def/thrift def. Some of the json I even work with is given a spec with protobuf and loaded that way which gives you type support. protobuf can generate python type stubs with mypy-protobuf. One practical annoyance is many libraries that use protobuf generated code don't currently include type stubs with them. I currently just make the stubs myself, but that is something most people would probably get stuck on and just needs more libraries to update the build scripts to include them in wheels. XML could have a similar approach although I'm not sure if anyone has done it already. Second talk (30 minute mark) of this video, https://www.youtube.com/watch?v=ld9rwCvGdhc |
|