• 
      

    Improve typing for all reviewboard.accounts fields and relations.

    Review Request #15499 — Created Nov. 11, 2026 and updated

    Information

    Review Board
    release-9.x

    Reviewers

    Since we first introduced type hints into the codebase, the one problem
    area has been field and field relations. We used to use django-stubs's
    extension to mypy to try to provide these for us automatically, but
    modern type checkers don't support plugins or this level of
    introspection, so any relation fields and any reverse relations came
    back as Unknown or with an error.

    The lack of typing has obscured a lot of bad assumptions in the
    codebase, which will need to be fixed separately.

    This change adds the beginning of this through explicit type hints to
    all relation fields, and documenting reverse relations. The field type
    hints define an annotation instead of using the generic form of the
    class, because not all Django field types support these equally.

    Relation fields also have a _id: ... type hint grouped with the
    relation, so we don't get errors when checking these.

    To keep things clean and manageable going forward, all fields have been
    updated to keep a uniform style. A lot of our fields were messy and hard
    to read and were almost 20 years old. The new form follows how we tend
    to style structures today.

    While the set of changes will be mostly comprehensive, I've opted to
    skip some that aren't likely to come up in practice (e.g., default
    reverse relations using *_set naming or those on Screenshot or
    ScreenshotComment).

    Other modules will be updated through follow-up changes.

    Unit tests passed.

    Ran through mypy and pyright, and had Claude do a pass.

    Summary ID
    Improve typing for all reviewboard.accounts fields and relations.
    Since we first introduced type hints into the codebase, the one problem area has been field and field relations. We used to use django-stubs's extension to mypy to try to provide these for us automatically, but modern type checkers don't support plugins or this level of introspection, so any relation fields and any reverse relations came back as `Unknown` or with an error. The lack of typing has obscured a lot of bad assumptions in the codebase, which will need to be fixed separately. This change adds the beginning of this through explicit type hints to all relation fields, and documenting reverse relations. The field type hints define an annotation instead of using the generic form of the class, because not all Django field types support these equally. Relation fields also have a `_id: ...` type hint grouped with the relation, so we don't get errors when checking these. To keep things clean and manageable going forward, all fields have been updated to keep a uniform style. A lot of our fields were messy and hard to read and were almost 20 years old. The new form follows how we tend to style structures today. While the set of changes will be mostly comprehensive, I've opted to skip some that aren't likely to come up in practice (e.g., default reverse relations using `*_set` naming or those on `Screenshot` or `ScreenshotComment`). Other modules will be updated through follow-up changes.
    1e858d4f4fd1dca3d1dcd929f8a6c9c095d08a35
    Description From Last Updated

    Maybe "associated with" instead of "owned by"?

    david david

    typo: targetting -> targeting

    david david

    typo: targetting -> targeting

    david david
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    david
    1. 
        
    2. reviewboard/accounts/models.py (Diff revision 1)
       
       
      Show all issues

      Maybe "associated with" instead of "owned by"?

    3. reviewboard/accounts/models.py (Diff revision 1)
       
       
      Show all issues

      typo: targetting -> targeting

    4. reviewboard/accounts/models.py (Diff revision 1)
       
       
      Show all issues

      typo: targetting -> targeting

    5.