Modernize and update the API capabilities object.

Review Request #12608 — Created Sept. 19, 2022 and submitted

david
RBTools
release-4.x
rbtools

This small change updates the API capabilities object with modern docs
and type annotations.

Ran unit tests.

Summary
Modernize and update the API capabilities object.
Description From Last Updated

We should use Dict[str, object] for this, to be a bit more explicit.

chipx86chipx86

I know it was this way before, but we probably don't need to capitalize capabilities.

chipx86chipx86

Missing a trailing period.

chipx86chipx86

This won't permit nested dictionaries or bools. It only allows a flat dictionary of string keys and values. Recursive dicts …

chipx86chipx86

Missing trailing comma.

chipx86chipx86

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

reviewbotreviewbot
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. rbtools/api/capabilities.py (Diff revision 1)
     
     

    We should use Dict[str, object] for this, to be a bit more explicit.

  3. rbtools/commands/__init__.py (Diff revision 1)
     
     

    I know it was this way before, but we probably don't need to capitalize capabilities.

  4. 
      
david
chipx86
  1. 
      
  2. rbtools/api/capabilities.py (Diff revision 2)
     
     

    Missing a trailing period.

  3. rbtools/api/capabilities.py (Diff revision 2)
     
     

    This won't permit nested dictionaries or bools. It only allows a flat dictionary of string keys and values.

    Recursive dicts are a problem and our capabilities don't have a specific nesting level for values. So we have to be generic with Dict[str, object].

    (object instead of Any, as the former ensures consistent type safety when reassigning values and the latter says "screw type safety.").

    1. Have to do some assertion nonsense down below to make this work with type checkers, but I guess that's OK.

    2. Nevermind, that fails. Going back to a very basic Dict definition.

  4. rbtools/api/capabilities.py (Diff revision 2)
     
     

    Missing trailing comma.

  5. 
      
david
Review request changed

Commits:

Summary
-
Modernize and update the API capabilities object.
+
Modernize and update the API capabilities object.

Diff:

Revision 3 (+112 -32)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.x (0a23c23)
Loading...