Add typing to reviews/detail.py

Review Request #14019 — Created July 9, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

This change adds type hints throughout our ReviewRequestPageData and
entry implementations.

Ran unit tests.

Summary ID
Add typing to reviews/detail.py
This change adds type hints throughout our ReviewRequestPageData and entry implementations. Testing Done: Ran unit tests.
f8b33c4d5e73098ec88af02b242d6f4b4297f155
Description From Last Updated

too many blank lines (3) Column: 1 Error code: E303

reviewbotreviewbot

The attributes section should be removed.

maubinmaubin

Can you add , optional here.

maubinmaubin

Can you add , optional here.

maubinmaubin

When taking things in, we should ideally use Sequence instead of list (unless we're assigning directly to a list).

chipx86chipx86

We should return a Mapping with a Sequence instead, so it's not mutable.

chipx86chipx86

Same here: Sequence and Mapping.

chipx86chipx86

I think Iterator is correct here, since the function yields items and is therefore an iterator, rather than returning something …

chipx86chipx86

We should maybe begin moving to keyword-only arguments. Note that subclasses would need any deprecation decorators applied to their versions …

chipx86chipx86

I feel like it'd be preferable to keep this up above where the other attributes are, and keep functions below …

chipx86chipx86

Summary must be on its own line.

chipx86chipx86

Summary must be on its own line.

chipx86chipx86

It'd be nice to move to keyword-only arguments here.

chipx86chipx86

It'd be nice to move to keyword-only arguments here. Same caveat as above.

chipx86chipx86

Should be a django.utils.safestring.SafeString.

chipx86chipx86

We should use Sequence or maybe Iterable here.

chipx86chipx86

Can we type this?

chipx86chipx86

Should maybe be Iterable.

chipx86chipx86

Here, too.

chipx86chipx86

Missing docs.

chipx86chipx86

This needs to be Type, given Python 3.8 compatibility.

chipx86chipx86

Should be Iterable.

chipx86chipx86

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

david
maubin
  1. 
      
  2. reviewboard/reviews/detail.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    The attributes section should be removed.

  3. reviewboard/reviews/detail.py (Diff revision 2)
     
     
    Show all issues

    Can you add , optional here.

  4. reviewboard/reviews/detail.py (Diff revision 2)
     
     
    Show all issues

    Can you add , optional here.

  5. 
      
david
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    When taking things in, we should ideally use Sequence instead of list (unless we're assigning directly to a list).

  3. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    We should return a Mapping with a Sequence instead, so it's not mutable.

  4. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
    Show all issues

    Same here: Sequence and Mapping.

  5. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    I think Iterator is correct here, since the function yields items and is therefore an iterator, rather than returning something that can be iterated over.

    Usually Iterator is taken in as something you want to iterate over, and Iterator (a subtype of Iterator) is returned as a thing from a function providing iteration.

    1. Type checking gets annoyed with that if the function (like in this case) doesn't actually yield anything.

  6. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
     
     
     
    Show all issues

    We should maybe begin moving to keyword-only arguments.

    Note that subclasses would need any deprecation decorators applied to their versions as well. Same with any other cases like this.

    1. Feel free to just put these aside for now, and track for another change.

  7. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
     
     
    Show all issues

    I feel like it'd be preferable to keep this up above where the other attributes are, and keep functions below any attributes, even if they're classmethods. These get heavily buried otherwise.

  8. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
    Show all issues

    Summary must be on its own line.

  9. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
    Show all issues

    Summary must be on its own line.

  10. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
     
    Show all issues

    It'd be nice to move to keyword-only arguments here.

  11. reviewboard/reviews/detail.py (Diff revision 3)
     
     
     
    Show all issues

    It'd be nice to move to keyword-only arguments here.

    Same caveat as above.

  12. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Should be a django.utils.safestring.SafeString.

  13. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    We should use Sequence or maybe Iterable here.

  14. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Can we type this?

  15. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Should maybe be Iterable.

  16. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Here, too.

  17. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Missing docs.

  18. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    This needs to be Type, given Python 3.8 compatibility.

  19. reviewboard/reviews/detail.py (Diff revision 3)
     
     
    Show all issues

    Should be Iterable.

  20. 
      
david
Review request changed
Commits:
Summary ID
Add typing to reviews/detail.py
This change adds type hints throughout our ReviewRequestPageData and entry implementations. Testing Done: Ran unit tests.
46d0af1834f6d1b8baa631856f0edd845f71ae6e
Add typing to reviews/detail.py
This change adds type hints throughout our ReviewRequestPageData and entry implementations. Testing Done: Ran unit tests.
5e627ae8571b43d2d0ccd4fae4b16e6917d5e49c

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.x (0d4c04f)