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

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

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.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
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 David Trowbridge
rbintegrations/testing/testcases.py
Loading...