Add typing to Review Bot's resources.
Review Request #14710 — Created Dec. 1, 2025 and submitted
This adds typing to Review Bot's resources.
Used in an upcoming change.
| Summary | ID |
|---|---|
| f2fabb06fb3394d54173527242669209340d9a37 |
| Description | From | Last Updated |
|---|---|---|
|
While here, can you update the name to use our standard naming? _normalize_comments_json? |
|
|
|
It might be nice to define a TypedDict that documents/enforces the interface on this. |
|
|
|
Since this is inside if TYPE_CHECKING it should be fine to import without the try/except. |
|
|
|
_normalize_comments_json doesn't treat this as a required key. We probably should make this be NotRequired[...] |
|
|
|
This should be HttpRequest, not ReviewRequest |
|
|
|
While here let's switch this to "Create" |
|
|
|
This should be fixed up too. |
|
|
|
diff_comments_norm here is a Sequence[DiffCommentData], which implies immutability, but the pop is mutating the dicts inside the sequence. The pop … |
|
|
|
Since extra_keys is typed as a sequence and base_comment_keys will likely get typed as a list, this will flag in … |
|
|
|
'collections.abc.Sequence' imported but unused Column: 5 Error code: F401 |
|
|
|
I think we can use Mapping here, if we're not modifying this anywhere. |
|
|
|
These can probably be Sequence, unless we're modifying them or passing them somewhere that requires a list. |
|
- Change Summary:
-
- Moved to release 4.1.
- Added typed dicts for normalized comment data.
- Fixed the comment normalization method name.
- Commits:
-
Summary ID 43a9d98a4a12bedeb2e5209ee4ba467e5055a635 6c19fb57b52f0465e68705b5911db76998fc2d46 - Diff:
-
Revision 2 (+256 -62)
Checks run (2 succeeded)
-
-
-
_normalize_comments_jsondoesn't treat this as a required key. We probably should make this beNotRequired[...] -
-
-
-
diff_comments_normhere is aSequence[DiffCommentData], which implies immutability, but the pop is mutating the dicts inside the sequence. The pop also makes it no longer satisfy theDiffCommentDatainterface. -
Since
extra_keysis typed as a sequence andbase_comment_keyswill likely get typed as a list, this will flag in some type checkers. We probably should doexpected_keys = set(base_comment_keys) | set(extra_keys)
- Commits:
-
Summary ID 6c19fb57b52f0465e68705b5911db76998fc2d46 caf43a925ac2dd45f14a6f7af57948134e0dfdf2 - Diff:
-
Revision 3 (+284 -80)
- Commits:
-
Summary ID caf43a925ac2dd45f14a6f7af57948134e0dfdf2 f2fabb06fb3394d54173527242669209340d9a37 - Diff:
-
Revision 4 (+282 -80)