Modernized function typing in reviewboard/accounts/models.py

Review Request #14106 — Created Aug. 16, 2024 and submitted

Information

Review Board
master

Reviewers

Modernized function typing in reviewboard/accounts/models.py

No new tests were added, however the entire reviewboard test suite
was run and all previously passing tests still pass.

Summary ID Author
Modernized function typing in reviewboard/accounts/models.py
Added typing to all the function parameters and return types in every function to bring the file in line with more modern typing standards. Certain type imports were put under a `TYPE_CHECKING`. No new tests were added, however the entire `reviewboard` test suite was run and all previously passing tests still pass.
3e36873cc624c53798cfa815d192edeb9ecea6f2 Daniel
Description From Last Updated

Below, you changed models.Model to be Model, but you didn't change the imports here.

daviddavid

Let's add a "Returns:" section to the comment too.

daviddavid

This needs a trailing comma. Same for many others in this change.

daviddavid

Let's add "Returns:" here too.

daviddavid

This should be typed as Group

daviddavid

'xhrUnknownErrorText' is defined but never used. Column: 7 Error code: W098

reviewbotreviewbot

While we usually treat long imports like this, for typing imports we try to fit as many as them on …

maubinmaubin

The closing """ should be on its own line.

maubinmaubin

While you're here, can you add a Type: bool after the description in the docstring.

maubinmaubin

The closing """ should be on its own line.

maubinmaubin

While these types are correct, we actually don't use type annotations for *args and **kwargs, so you can remove the …

maubinmaubin

Same comment here for **kwargs, we can remove the type.

maubinmaubin
dan.casares
david
  1. 
      
  2. reviewboard/accounts/models.py (Diff revision 2)
     
     
     
    Show all issues

    Below, you changed models.Model to be Model, but you didn't change the imports here.

  3. reviewboard/accounts/models.py (Diff revision 2)
     
     
    Show all issues

    Let's add a "Returns:" section to the comment too.

  4. reviewboard/accounts/models.py (Diff revision 2)
     
     
    Show all issues

    This needs a trailing comma. Same for many others in this change.

  5. reviewboard/accounts/models.py (Diff revision 2)
     
     
    Show all issues

    Let's add "Returns:" here too.

  6. reviewboard/accounts/models.py (Diff revision 2)
     
     
    Show all issues

    This should be typed as Group

  7. 
      
dan.casares
Review request changed
Commits:
Summary ID Author
Modernized function typing in reviewboard/accounts/models.py
Added typing to all the function parameters and return types in every function to bring the file in line with more modern typing standards. Certain type imports were put under a `TYPE_CHECKING`. No new tests were added, however the entire `reviewboard` test suite was run and all previously passing tests still pass.
0149e77fc2277cd24c0c5745e3b32f6c6134e5cc Daniel
Modernized function typing in reviewboard/accounts/models.py
Added typing to all the function parameters and return types in every function to bring the file in line with more modern typing standards. Certain type imports were put under a `TYPE_CHECKING`. No new tests were added, however the entire `reviewboard` test suite was run and all previously passing tests still pass.
d72bc111c58e20f2fa7a9a78eac84e1d0f19e14a Daniel

Checks run (1 failed, 1 succeeded)

flake8 passed.
JSHint failed.

JSHint

dan.casares
maubin
  1. Thanks for modernizing this.

  2. reviewboard/accounts/models.py (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
    Show all issues

    While we usually treat long imports like this, for typing imports we try to fit as many as them on one line as possible because its very common for us to import a lot of things from typing. So this should look like this instead:

    from typing import (Any, ClassVar, Dict, List, Optional, Set, Tuple,
                        TYPE_CHECKING, Union)
    
  3. reviewboard/accounts/models.py (Diff revision 4)
     
     
    Show all issues

    The closing """ should be on its own line.

  4. reviewboard/accounts/models.py (Diff revision 4)
     
     
     
     
     
     
     
     
    Show all issues

    While you're here, can you add a

    Type:
        bool
    

    after the description in the docstring.

  5. reviewboard/accounts/models.py (Diff revision 4)
     
     
    Show all issues

    The closing """ should be on its own line.

  6. reviewboard/accounts/models.py (Diff revision 4)
     
     
     
    Show all issues

    While these types are correct, we actually don't use type annotations for *args and **kwargs, so you can remove the types here. I'm not really sure why we don't type them.

  7. reviewboard/accounts/models.py (Diff revision 4)
     
     
    Show all issues

    Same comment here for **kwargs, we can remove the type.

  8. 
      
dan.casares
maubin
  1. Ship It!
  2. 
      
dan.casares
Review request changed
Status:
Completed