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
Add type annotations for primary key types by model #436
This is a type hardening which we'd discussed in Slack. Basically, we'd subtype int into things like ForeignKey[Component] so that mypy can call out cases where you passed in the wrong model's ForeignKey. This is especially important for Learning Core because the APIs generally accept FKs (as an optimization) rather than model instances, data objects, or opaque keys.
I'm marking this as done now, though I haven't applied typed keys to all our models yet. (e.g. I didn't yet do PublishableEntityVersion, Media, MediaType, ContainerType, tagging models, etc.) If there's any other models you'd like me to change over to use fully typed keys now, just let me know.
The new TypedBigAutoField and TypedAutoField are also now available in openedx-platform, to use on any models we'd like there. Maybe once OEP-68 is finalized, we can try to evangelize this a bit among platform devs.
Activity
kdmccormick commentedon Jan 15, 2026
This is a type hardening which we'd discussed in Slack. Basically, we'd subtype
intinto things likeForeignKey[Component]so that mypy can call out cases where you passed in the wrong model's ForeignKey. This is especially important for Learning Core because the APIs generally accept FKs (as an optimization) rather than model instances, data objects, or opaque keys.I'll let @ormsbee paste in the details.
kdmccormick commentedon Apr 13, 2026
Implemented by:
bradenmacdonald commentedon Apr 13, 2026
I'm marking this as done now, though I haven't applied typed keys to all our models yet. (e.g. I didn't yet do
PublishableEntityVersion,Media,MediaType,ContainerType, tagging models, etc.) If there's any other models you'd like me to change over to use fully typed keys now, just let me know.bradenmacdonald commentedon Apr 13, 2026
The new
TypedBigAutoFieldandTypedAutoFieldare also now available in openedx-platform, to use on any models we'd like there. Maybe once OEP-68 is finalized, we can try to evangelize this a bit among platform devs.kdmccormick commentedon Apr 13, 2026
Cool, I made #538 so that we remember to update the OEP. Can be after Verawood, once we've had a chance to use annotations these for a bit.
fix: create GitHub release with assets attached, not after publish