Python: fix(core): accept a bare container type as an edge target for a parameterized output - #8731
Open
Anish Mehta (anishmehta24) wants to merge 2 commits into
Conversation
… a parameterized output
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 24, 2026 17:12 — with
GitHub Actions
Active
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 24, 2026 17:12 — with
GitHub Actions
Active
|
|
||
| # A bare container class on one side (list[str] -> list, or list -> list[str]): | ||
| # the unparameterized side accepts any element type, so compare the containers. | ||
| if target_origin is None and isinstance(target_type, type) and isinstance(source_origin, type): |
There was a problem hiding this comment.
Anish Mehta (@anishmehta24) This still rejects bare aliases from typing, such as list[str] -> typing.Sequence: typing.Sequence has an origin and no type arguments, so neither new bare-container branch matches and the different-container check rejects it. Please treat origin-with-empty-args aliases as bare containers and add a regression for this case.
Contributor
Author
There was a problem hiding this comment.
Updated so a bare typing alias with no type args, like typing.Sequence or typing.List, gets treated as the plain container it stands for before the checks run. I added list[str] -> typing.Sequence and a few other typing alias cases to the regression test.
Anish Mehta (anishmehta24)
deployed
to
github-app-auth
September 29, 2026 04:36 — with
GitHub Actions
Active
This branch was successfully deployed
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.
Motivation & Context
A handler that takes a plain
list(ordict,tuple,Sequence) can't receive a parameterized output from an upstream executor. The workflow fails to build:is_type_compatiblecomparesget_origin(list[str])(list) withget_origin(list)(None) in Case 5 and returns False before the "one side is untyped, assume compatible" rule in Case 6 is reached. The runtime check already accepts the message. The reverse,list -> list[str], fails the same way.Description & Review Guide
issubclass.list[str] -> list,dict[str, int] -> dict,list[int] -> Sequenceandlist -> list[str]are now compatible;list[str] -> dictstill isn't.list[Message] -> Sequence[Message](both parameterized, different containers) is still rejected by Case 5. I left that out to keep this small.Related Issue
No existing issue.
Contribution Checklist
Tests: a unit case in
test_typing_utils.pyand a workflow build intest_validation.py; both fail on main.pytest packages/core/tests/workflowpasses, and ruff and the repo's pre-commit checks are clean.