Skip to content

Add type annotations for primary key types by model #436

Closed

Description

@ormsbee

@ormsbee: fill out details.

Activity

  1. kdmccormick commented on Jan 15, 2026

    @kdmccormick
    Member

    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'll let @ormsbee paste in the details.

  2. bradenmacdonald commented on Apr 13, 2026

    @bradenmacdonald
    Contributor

    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.

  3. bradenmacdonald commented on Apr 13, 2026

    @bradenmacdonald
    Contributor

    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.

  4. kdmccormick commented on Apr 13, 2026

    @kdmccormick
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions