Add typing for the functions in TestCase.

Review Request #14035 — Created July 13, 2024 and submitted

Information

RBTools
release-5.x

Reviewers

This updates TestCase to add type hints all throughout. This helps
ensure we pass in the right typse to functions, and that we get the
right transport and client types when setting up state for API tests.

Unit tests pass.

Summary ID
Add typing for the functions in TestCase.
This updates `TestCase` to add type hints all throughout. This helps ensure we pass in the right typse to functions, and that we get the right transport and client types when setting up state for API tests.
98ad375cdd0626813277d9f77586bde3b28e185a
Description From Last Updated

'typing.Any' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

redefinition of unused 'RBClient' from line 17 Column: 5 Error code: F811

reviewbotreviewbot

While you're here, mind adding docstrings and changing to super()?

daviddavid

Here too.

daviddavid

Now that we're properly using __future__.annotations, we should change from Dict to dict and List to list.

daviddavid

Blank line between these two.

daviddavid

Can we add a doc comment for this?

daviddavid

maxDiff doesn't appear to be used anywhere within the rbtools codebase. Can we just get rid of this?

daviddavid

Should probably be Any instead of object.

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

flake8

chipx86
david
  1. 
      
  2. rbtools/testing/testcase.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    While you're here, mind adding docstrings and changing to super()?

  3. rbtools/testing/testcase.py (Diff revision 2)
     
     
     
    Show all issues

    Here too.

  4. 
      
chipx86
david
  1. 
      
  2. rbtools/testing/testcase.py (Diff revision 3)
     
     
    Show all issues

    Now that we're properly using __future__.annotations, we should change from Dict to dict and List to list.

  3. rbtools/testing/testcase.py (Diff revision 3)
     
     
     
    Show all issues

    Blank line between these two.

  4. rbtools/testing/testcase.py (Diff revision 3)
     
     
    Show all issues

    Can we add a doc comment for this?

  5. rbtools/testing/testcase.py (Diff revision 3)
     
     
    Show all issues

    maxDiff doesn't appear to be used anywhere within the rbtools codebase. Can we just get rid of this?

    1. This tells TestCase that we don't want a limit when comparing strings, dictionaries, lists, etc. By default it's a low number. We can either set to a number or use None to let it just compare without truncation messages. None ends up being a good option the majority of the time in our cases.

  6. rbtools/testing/testcase.py (Diff revision 3)
     
     
    Show all issues

    Should probably be Any instead of object.

    1. object is considered safer than Any if you want type checking, since Any just turns off type checking for the variable. object fits with the usage of these methods and still gives us type checking so that, say, config['foo'] + 1 would generate a type error instead of silently appearing to work. Sometimes Any is appropriate, but probably not here.

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