Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nodes): improve types in graph.py #5656

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

psychedelicious
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Description

Methods get_node and complete were typed as returning a dynamically created unions InvocationsUnion and InvocationOutputsUnion, respectively.

Static type analysers cannot work with dynamic objects, so these methods end up as effectively un-annotated, returning Unknown.

They now return BaseInvocation and BaseInvocationOutput, respectively, which are the superclasses of all members of each union. This gives us the best type annotation that is possible.

Note: the return types of these methods are never introspected, so it doesn't really matter what they are at runtime.

Merge Plan

This PR can be merged when approved

@github-actions github-actions bot added python PRs that change python files services PRs that change app services labels Feb 5, 2024
Methods `get_node` and `complete` were typed as returning a dynamically created unions `InvocationsUnion` and `InvocationOutputsUnion`, respectively.

Static type analysers cannot work with dynamic objects, so these methods end up as effectively un-annotated, returning `Unknown`.

They now return `BaseInvocation` and `BaseInvocationOutput`, respectively, which are the superclasses of all members of each union. This gives us the best type annotation that is possible.

Note: the return types of these methods are never introspected, so it doesn't really matter what they are at runtime.
@psychedelicious psychedelicious merged commit 3726293 into main Feb 13, 2024
8 checks passed
@psychedelicious psychedelicious deleted the feat/nodes/graph-method-types branch February 13, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs that change python files services PRs that change app services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants