Enhance typing for KeyValueForm.

Review Request #14437 — Created May 13, 2025 and submitted — Latest diff uploaded

Information

Djblets
release-6.x

Reviewers

This change makes it so KeyValueForm is typed as a generic, allowing us
to specify the type of the instance member which is operated on. The
default implementations of get and set assume a dict-like interface, so
I've additionally added some runtime-checkable protocols for those.

  • Ran unit tests.
  • Verified that type checkers were happy when creating KeyValueForm
    subclasses.

Changes between revision 2 and 3

orig
1
2
3
4

Commits

Summary ID Author
Enhance typing for KeyValueForm.
This change makes it so KeyValueForm is typed as a generic, allowing us to specify the type of the `instance` member which is operated on. The default implementations of get and set assume a dict-like interface, so I've additionally added some runtime-checkable protocols for those. Testing Done: - Ran unit tests. - Verified that type checkers were happy when creating KeyValueForm subclasses.
97a611feae2ea8969aadad0f0c2ac23b45907d16 David Trowbridge
Enhance typing for KeyValueForm.
This change makes it so KeyValueForm is typed as a generic, allowing us to specify the type of the `instance` member which is operated on. The default implementations of get and set assume a dict-like interface, so I've additionally added some runtime-checkable protocols for those. Testing Done: - Ran unit tests. - Verified that type checkers were happy when creating KeyValueForm subclasses.
0f1b47e7c005ef5967703aa1dc2d470f69e1e035 David Trowbridge
djblets/forms/forms/key_value_form.py
djblets/siteconfig/forms.py
Loading...