I started an effort to do this a few years ago (see https://github.com/sprockets/sprockets.mixins.mediatype/pull/23) but it fizzled since the typing SIG was still changing things. Now that things have settled done in the part of the ecosystem, I'd like to reboot it. I still like the approach that I took in my original branch:
add type definitions for precisely we know how to serialize -- IOW, define a union type like SerializableTypes
document the definitions and expected usage
pull mypy (maybe pyright?) into the build chain
The one downside is that typing.Protocol was added in 3.8 and we still support 3.7. We can use the typing.extensions package as a backport. For this reason, I would isolate the typing-related classes into a module named sprockets.mixins.mediatype.type_info and use it in conjunction with typing. The goal is to not let the non-3.7 compatibility stuff leak out of the module.
Feel free to steal, adopt, and/or ignore portions of my original branch.
I started an effort to do this a few years ago (see https://github.com/sprockets/sprockets.mixins.mediatype/pull/23) but it fizzled since the typing SIG was still changing things. Now that things have settled done in the part of the ecosystem, I'd like to reboot it. I still like the approach that I took in my original branch:
SerializableTypes
The one downside is that
typing.Protocol
was added in 3.8 and we still support 3.7. We can use the typing.extensions package as a backport. For this reason, I would isolate the typing-related classes into a module namedsprockets.mixins.mediatype.type_info
and use it in conjunction withtyping
. The goal is to not let the non-3.7 compatibility stuff leak out of the module.Feel free to steal, adopt, and/or ignore portions of my original branch.