• 
      

    Update typing and other modernization in git client.

    Review Request #14324 — Created Feb. 3, 2025 and submitted

    Information

    RBTools
    master

    Reviewers

    This change does some improvements to our type hints, fixes up some doc
    typos/errors, and moves to more modern syntax for a few things
    (f-strings, list construction, etc).

    Ran unit tests.

    Summary ID
    Update typing and other modernization in git client.
    This change does some improvements to our type hints, fixes up some doc typos/errors, and moves to more modern syntax for a few things (f-strings, list construction, etc). Testing Done: Ran unit tests.
    e3a0b6882dd5dbae4a4e3531a0d3d855b6bae9e1
    Description From Last Updated

    At this point it'd be nice to just wrap these as a typical multi-line list with one item per line. …

    chipx86chipx86

    Instead of casting (here and below), we should probably assert.

    chipx86chipx86

    Instead of a cast, let's assert instead.

    chipx86chipx86

    For here and other messages, I think the right move is to keep these as-is and start wrapping in gettext. …

    chipx86chipx86

    Small thing, but when just consuming, we should use Sequence.

    chipx86chipx86

    Can you put these in alphabetical order?

    chipx86chipx86

    Nit: I think this should be Union[str, Sequence[str]]

    maubinmaubin

    Nit: I think this should be Sequence[bytes]

    maubinmaubin

    Same here.

    maubinmaubin

    Also a nit: While here can you wrap None in double backticks

    maubinmaubin

    Same Sequence nit here.

    maubinmaubin

    Same Sequence nit here.

    maubinmaubin

    Since we're changing this, we should maybe use Sequence now.

    chipx86chipx86

    We shouldn't override types in subclasses. They should be defined once in the parent, so the type checker can verify …

    chipx86chipx86

    This should probably be a Mapping.

    chipx86chipx86

    Localized strings with multiple variables need to use names instead of positional markers. Also, why the change in the code …

    chipx86chipx86

    This should maybe return a Sequence, unless we should be modifying the result.

    chipx86chipx86

    This needs to continue using named placeholders.

    chipx86chipx86

    Here, too.

    chipx86chipx86

    This should maybe be a Mapping.

    chipx86chipx86

    This type is set in the parent, so we shouldn't override it here.

    chipx86chipx86

    multiple spaces before operator Column: 17 Error code: E221

    reviewbotreviewbot

    multiple spaces before operator Column: 22 Error code: E221

    reviewbotreviewbot

    multiple spaces before operator Column: 20 Error code: E221

    reviewbotreviewbot

    multiple spaces before operator Column: 35 Error code: E221

    reviewbotreviewbot

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

    reviewbotreviewbot

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

    reviewbotreviewbot
    chipx86
    1. Very nice cleanup. Got a few small suggestions, mostly around ensuring type safety.

    2. rbtools/clients/git.py (Diff revision 1)
       
       
       
      Show all issues

      At this point it'd be nice to just wrap these as a typical multi-line list with one item per line.

      We should probably also type as ClassVar[Sequence[str]]

    3. rbtools/clients/git.py (Diff revision 1)
       
       
      Show all issues

      Instead of casting (here and below), we should probably assert.

    4. rbtools/clients/git.py (Diff revision 1)
       
       
      Show all issues

      Instead of a cast, let's assert instead.

    5. rbtools/clients/git.py (Diff revision 1)
       
       
       
       
      Show all issues

      For here and other messages, I think the right move is to keep these as-is and start wrapping in gettext. The newer bits of code (Patcher, Patch, soem errors, a couple SCMs) are using gettext.

    6. rbtools/clients/tests/test_git.py (Diff revision 1)
       
       
      Show all issues

      Small thing, but when just consuming, we should use Sequence.

    7. rbtools/clients/tests/test_git.py (Diff revision 1)
       
       
       
       
       
       
       
       
       
      Show all issues

      Can you put these in alphabetical order?

    8. 
        
    david
    maubin
    1. 
        
    2. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Nit: I think this should be Union[str, Sequence[str]]

    3. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Nit: I think this should be Sequence[bytes]

    4. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Same here.

    5. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Also a nit: While here can you wrap None in double backticks

    6. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Same Sequence nit here.

    7. rbtools/clients/git.py (Diff revision 2)
       
       
      Show all issues

      Same Sequence nit here.

    8. 
        
    david
    maubin
    1. Ship It!
    2. 
        
    chipx86
    1. 
        
    2. rbtools/clients/git.py (Diff revision 3)
       
       
      Show all issues

      Since we're changing this, we should maybe use Sequence now.

    3. rbtools/clients/git.py (Diff revision 3)
       
       
       
      Show all issues

      We shouldn't override types in subclasses. They should be defined once in the parent, so the type checker can verify the assigned value against the parent type. Same goes for the ones below.

    4. rbtools/clients/git.py (Diff revision 3)
       
       
      Show all issues

      This should probably be a Mapping.

    5. rbtools/clients/git.py (Diff revision 3)
       
       
       
       
       
      Show all issues

      Localized strings with multiple variables need to use names instead of positional markers.

      Also, why the change in the code to .format() instead of %? I'm not opposed, but we've never really bothered with the former before.

      1. I feel like we should be moving towards f-strings and .format() as a rule, since it's generally more readable and has a lot fewer quirks.

    6. rbtools/clients/git.py (Diff revision 3)
       
       
      Show all issues

      This should maybe return a Sequence, unless we should be modifying the result.

    7. rbtools/clients/git.py (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      This needs to continue using named placeholders.

    8. rbtools/clients/git.py (Diff revision 3)
       
       
       
       
       
       
      Show all issues

      Here, too.

    9. rbtools/clients/git.py (Diff revision 3)
       
       
      Show all issues

      This should maybe be a Mapping.

    10. rbtools/clients/tests/test_git.py (Diff revision 3)
       
       
       
      Show all issues

      This type is set in the parent, so we shouldn't override it here.

    11. 
        
    david
    Review request changed
    Commits:
    Summary ID
    Update typing and other modernization in git client.
    This change does some improvements to our type hints, fixes up some doc typos/errors, and moves to more modern syntax for a few things (f-strings, list construction, etc). Testing Done: Ran unit tests.
    ec5312625ffb8a58d94f15084bb6ce12dff411fd
    Update typing and other modernization in git client.
    This change does some improvements to our type hints, fixes up some doc typos/errors, and moves to more modern syntax for a few things (f-strings, list construction, etc). Testing Done: Ran unit tests.
    ff9479e44b3dc471d00792fda5ba9627844fce58

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    david
    Review request changed
    Commits:
    Summary ID
    Update typing and other modernization in git client.
    This change does some improvements to our type hints, fixes up some doc typos/errors, and moves to more modern syntax for a few things (f-strings, list construction, etc). Testing Done: Ran unit tests.
    ff9479e44b3dc471d00792fda5ba9627844fce58
    Update typing and other modernization in git client.
    This change does some improvements to our type hints, fixes up some doc typos/errors, and moves to more modern syntax for a few things (f-strings, list construction, etc). Testing Done: Ran unit tests.
    e7a8b082115d25662179d1c709dca5770d51ff5b

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    david
    david
    maubin
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (9e4b1d4)