Repository navigation
Fix type checks for explicit nodes, generics and unions - #71
Open
LucaMantani wants to merge 1 commit into
Open
LucaMantani wants to merge 1 commit into
LucaMantani wants to merge 1 commit into
Conversation
check_types compared the ExplicitNode placeholder of an @explicit_node resource against the annotation of the value it will produce, which can never match. Skip it, as provider outputs are skipped. Annotation checks (check_types, parse_ inputs, allowed_keys) now go through check_annotation, which checks parametrised generics against their origin class and unions member-wise, instead of raising a bare TypeError from isinstance. BadInputType also names unions and generics instead of failing with AttributeError on types.UnionType. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
resourcebuilder.check_types(and theparse_/allowed_keyschecks inconfigparser) callisinstance(value, annotation)directly. That breaks with three common annotation patterns:@explicit_noderesources. When a provider parameter is filled by an@explicit_nodeproduce_X, the namespace still holds theExplicitNodewrapper at check time (_process_requirementturns its.valueinto a node of its own). The real value doesn't exist yet, so any correct annotation fails:BadInputType: Value '<ExplicitNode ...>' is not of type Union, but of type 'ExplicitNode'.Provider outputs are never checked at this stage, so this change skips
ExplicitNodevalues in the same way.def provider(settings: Mapping[str, Any])crashes graph building with a bareTypeError: isinstance() argument 2 cannot be a parameterized generic, without naming the provider or parameter.X | Noneon Python 3.10–3.13. When the check fails,BadInputTypeitself raisesAttributeError: 'types.UnionType' object has no attribute '__name__'.Changes
configparser.check_annotation(val, tp). It behaves likeisinstancefor classes and tuples, matches unions if any member matches, and checks generics against their origin class (type arguments are not validated). It's used bycheck_types,_parse_funcandcheck_key_is_allowed.check_typesskipsExplicitNodevalues.BadInputTypenames unions and generics viastr(tp).test_builder.py(explicit node + generic/union provider annotations, origin mismatch) andtest_configparser.py(generic/unionparse_inputs). All three fail onmaster.The full suite passes on Python 3.11 and 3.14, except
test_collectandtest_parallel_execute. Those two fail identically onmaster: recentdistributedremovedClient.register_worker_plugin.Context: found in smefit, where adding type hints to a provider broke the graph.
🤖 Generated with Claude Code