• 
      

    Add typing to Review Bot's resources.

    Review Request #14710 — Created Dec. 1, 2025 and submitted

    Information

    ReviewBot
    release-4.x

    Reviewers

    This adds typing to Review Bot's resources.

    Used in an upcoming change.

    Summary ID
    Add typing to Review Bot's resources.
    This adds typing to Review Bot's resources.
    f2fabb06fb3394d54173527242669209340d9a37
    Description From Last Updated

    While here, can you update the name to use our standard naming? _normalize_comments_json?

    chipx86chipx86

    It might be nice to define a TypedDict that documents/enforces the interface on this.

    daviddavid

    Since this is inside if TYPE_CHECKING it should be fine to import without the try/except.

    daviddavid

    _normalize_comments_json doesn't treat this as a required key. We probably should make this be NotRequired[...]

    daviddavid

    This should be HttpRequest, not ReviewRequest

    daviddavid

    While here let's switch this to "Create"

    daviddavid

    This should be fixed up too.

    daviddavid

    diff_comments_norm here is a Sequence[DiffCommentData], which implies immutability, but the pop is mutating the dicts inside the sequence. The pop …

    daviddavid

    Since extra_keys is typed as a sequence and base_comment_keys will likely get typed as a list, this will flag in …

    daviddavid

    'collections.abc.Sequence' imported but unused Column: 5 Error code: F401

    reviewbotreviewbot

    I think we can use Mapping here, if we're not modifying this anywhere.

    chipx86chipx86

    These can probably be Sequence, unless we're modifying them or passing them somewhere that requires a list.

    chipx86chipx86
    david
    1. 
        
    2. extension/reviewbotext/resources.py (Diff revision 1)
       
       
      Show all issues

      It might be nice to define a TypedDict that documents/enforces the interface on this.

    3. 
        
    chipx86
    1. 
        
    2. extension/reviewbotext/resources.py (Diff revision 1)
       
       
      Show all issues

      While here, can you update the name to use our standard naming? _normalize_comments_json?

    3. 
        
    maubin
    david
    1. 
        
    2. extension/reviewbotext/resources.py (Diff revision 2)
       
       
       
       
       
       
      Show all issues

      Since this is inside if TYPE_CHECKING it should be fine to import without the try/except.

    3. extension/reviewbotext/resources.py (Diff revision 2)
       
       
       
      Show all issues

      _normalize_comments_json doesn't treat this as a required key. We probably should make this be NotRequired[...]

      1. It's not one of the expected keys from the JSON payload but we do always set it based on issue_opened, so it'll always appear in the comment data returned from _normalize_comments_json.

    4. extension/reviewbotext/resources.py (Diff revision 2)
       
       
      Show all issues

      This should be HttpRequest, not ReviewRequest

    5. extension/reviewbotext/resources.py (Diff revision 2)
       
       
      Show all issues

      While here let's switch this to "Create"

    6. extension/reviewbotext/resources.py (Diff revision 2)
       
       
       
       
      Show all issues

      This should be fixed up too.

    7. extension/reviewbotext/resources.py (Diff revision 2)
       
       
       
      Show all issues

      diff_comments_norm here is a Sequence[DiffCommentData], which implies immutability, but the pop is mutating the dicts inside the sequence. The pop also makes it no longer satisfy the DiffCommentData interface.

    8. extension/reviewbotext/resources.py (Diff revision 2)
       
       
      Show all issues

      Since extra_keys is typed as a sequence and base_comment_keys will likely get typed as a list, this will flag in some type checkers. We probably should do expected_keys = set(base_comment_keys) | set(extra_keys)

      1. I decided to just make everything sets from the get go.

    9. 
        
    maubin
    Review request changed
    Commits:
    Summary ID
    Add typing to Review Bot's resources.
    This adds typing to Review Bot's resources.
    6c19fb57b52f0465e68705b5911db76998fc2d46
    Add typing to Review Bot's resources.
    This adds typing to Review Bot's resources.
    caf43a925ac2dd45f14a6f7af57948134e0dfdf2

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    1. 
        
    2. extension/reviewbotext/resources.py (Diff revision 3)
       
       
      Show all issues

      I think we can use Mapping here, if we're not modifying this anywhere.

    3. extension/reviewbotext/resources.py (Diff revision 3)
       
       
      Show all issues

      These can probably be Sequence, unless we're modifying them or passing them somewhere that requires a list.

      1. We do modify them so they need to be a list.

    4. 
        
    maubin
    david
    1. Ship It!
    2. 
        
    maubin
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-4.x (b8ea697)