You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MyPy errors when using tomlkit to modify toml documents #326
IMO the types in tomlkit are more or less unusable: per this issue they generate a lot of noise and no help on the code that you want to write.
One approach to working around that goes something like this:
# pretend that we're just dealing with a regular dictionarydata: dict[str, Any] =tomlkit.parse(whatever)
...
# later cast back to the tomlkit type if some API requires itdata=cast("TOMLDocument", data)
which works: but of course it is just ceremony to suppress unhelpful errors, and abandons any potential benefits if the typing were more helpful.
For me, the current state of the typing is such that it would be better not to show it to users (ie remove py.typed).
If anyone cares to make the typing better, then of course that's better! Fixing the warnings and errors that mypy generates on this project and its unit tests would be a sensible way of going about that, though there is probably quite a lot of work - and maybe some of it is not easy - to get that done:
Activity
dimbleby commentedon Jan 1, 2024
IMO the types in tomlkit are more or less unusable: per this issue they generate a lot of noise and no help on the code that you want to write.
One approach to working around that goes something like this:
which works: but of course it is just ceremony to suppress unhelpful errors, and abandons any potential benefits if the typing were more helpful.
For me, the current state of the typing is such that it would be better not to show it to users (ie remove
py.typed).If anyone cares to make the typing better, then of course that's better! Fixing the warnings and errors that mypy generates on this project and its unit tests would be a sensible way of going about that, though there is probably quite a lot of work - and maybe some of it is not easy - to get that done: