• 
      

    Remove deprecation for passing non-string values to API add_field.

    Review Request #14489 — Created June 28, 2025 and submitted

    Information

    RBTools
    master

    Reviewers

    The API request add_field method has had a deprecation warning for a
    while about passing in values that are not either str or bytes. This
    change replaces the warning+cast with an exception.

    There were a few places inside RBTools itself that were still hitting
    this, all in the post implementation. These have been fixed up to format
    the values as strings.

    • Ran unit tests.
    • Audited call sites to verify that we were passing string types
      everywhere.
    • Posted changes, including ones that needed to upload binary files.
    Summary ID
    Remove deprecation for passing non-string values to API add_field.
    The API request `add_field` method has had a deprecation warning for a while about passing in values that are not either `str` or `bytes`. This change replaces the warning+cast with an exception. There were a few places inside RBTools itself that were still hitting this, all in the post implementation. These have been fixed up to format the values as strings. Testing Done: - Ran unit tests. - Audited call sites to verify that we were passing string types everywhere. - Posted changes, including ones that needed to upload binary files.
    7f16aed79145ff42fa8127f18108abd007bfd679
    Description From Last Updated

    We should prefix all strings with f when any in a multi-line string needs it. This avoids some warnings. What's …

    chipx86chipx86

    I feel like in the cases where we want to convert to a string, we should just cut out the …

    chipx86chipx86

    We should add a new version changed entry to say that only bytes and strings are accepted.

    maubinmaubin

    We can get rid of this.

    maubinmaubin
    chipx86
    1. 
        
    2. rbtools/api/request.py (Diff revision 1)
       
       
       
       
       
      Show all issues

      We should prefix all strings with f when any in a multi-line string needs it. This avoids some warnings.

      What's the type: ignore for?

      1. value is typed as bytes | str, so any code inside this if statement will be flagged as unreachable if we don't have this.

      2. Oh, that's surprisingly annoying.

        What happens if you instead add in there: assert not TYPE_CHECKING?

      3. The assert line gets flagged as unreachable (lol)

      4. Type checkers, why are you the way that you are.

        Okay, typing_extensions.assert_never() seems to be for this purpose.

      5. But notably would raise an exception. So we'd have to wrap in TYPE_CHECKING, I guess.

    3. rbtools/commands/post.py (Diff revision 1)
       
       
      Show all issues

      I feel like in the cases where we want to convert to a string, we should just cut out the middle-man and use str(...) directly. This avoids the extra processing and results in the same thing.

    4. 
        
    david
    maubin
    1. 
        
    2. rbtools/api/request.py (Diff revision 2)
       
       
      Show all issues

      We should add a new version changed entry to say that only bytes and strings are accepted.

    3. rbtools/api/request.py (Diff revision 2)
       
       
       
      Show all issues

      We can get rid of this.

    4. 
        
    david
    david
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (c03889f)