• 
      

    Make Generic[...] the last parent class for multiple inheritance.

    Review Request #14446 — Created May 20, 2025 and submitted

    Information

    rbintegrations
    release-4.x

    Reviewers

    When there are multiple generics in a class hierarchy, Python can easily
    hit a situation where it can't create a consistent MRO during
    construction. This is particularly annoying when we're trying to add
    generics to older code.

    The best solution seems to be to put Generic[...] as the last parent
    class instead of the first. In fact, the new PEP-695 syntax for generics
    does exactly this.

    Ran unit tests.

    Summary ID
    Make Generic[...] the last parent class for multiple inheritance.
    When there are multiple generics in a class hierarchy, Python can easily hit a situation where it can't create a consistent MRO during construction. This is particularly annoying when we're trying to add generics to older code. The best solution seems to be to put Generic[...] as the last parent class instead of the first. In fact, the new PEP-695 syntax for generics does exactly this. Testing Done: Ran unit tests.
    657be2caf206282f900934c02d82e05d5d950052
    maubin
    1. Ship It!
    2. 
        
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-4.x (1a6e4b8)