Replace duck typing with protocols for target and CustomTargetIndex types#15930
Open
bonzini wants to merge 8 commits into
Open
Replace duck typing with protocols for target and CustomTargetIndex types#15930bonzini wants to merge 8 commits into
bonzini wants to merge 8 commits into
Conversation
11 tasks
dnicolodi
reviewed
Jun 16, 2026
dnicolodi
reviewed
Jun 16, 2026
dnicolodi
reviewed
Jun 16, 2026
dnicolodi
reviewed
Jun 16, 2026
... where CustomTargetIndexes or even CustomTargets are not possible. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This is called with isinstance checks on CommandTypes, so the right type is BuildTargetTypes (coming from the Union). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Document precisely what is required, and in particular that AnyTargetProto is not hashable. The old type union is not needed anymore. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Document precisely what is required, the old type union is not needed anymore outside the interpreter. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Replace the abstract class LinkableTarget and the LinkableTargetTypes union with a protocol. For the abstract class, in particular, there are no concrete methods and there is no need for isinstance tests, so they are interchangeable. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Document precisely what's needed, and remove the last two union types. Union types should be reserved for "faking" sum types via isinstance. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR continues the idea of limiting Union to cases where individual members are categorized with
isinstancetests. Instead, cases where Meson mostly uses duck typing between CustomTargetBase and BuildTarget are now handled with protocols. Whileisinstancetests are occasionally used with types declared as*Prototypes, this use is relatively rare, especially in the interpreter->build interface.