Improve typing for all reviewboard.accounts fields and relations.
Review Request #15499 — Created Nov. 11, 2026 and updated
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 asUnknownor 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*_setnaming or those onScreenshotor
ScreenshotComment).Other modules will be updated through follow-up changes.
Unit tests passed.
Ran through mypy and pyright, and had Claude do a pass.