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

Properly Typing ClipTextEncode response #9

Open
M1kep opened this issue Aug 25, 2024 · 1 comment
Open

Properly Typing ClipTextEncode response #9

M1kep opened this issue Aug 25, 2024 · 1 comment

Comments

@M1kep
Copy link

M1kep commented Aug 25, 2024

I'm running issues typing the ClipTextEncode response as it's a tuple[list[list[torch.Tensor, dict]]] and __qualname__ doesn't exist on the types.UnionType.

ref: https://github.com/comfyanonymous/ComfyUI/blob/6ab1e6fd4a2f7cc5945310f0ecfc11617aa9a2cb/nodes.py#L47-L67

@andrewharp
Copy link
Owner

andrewharp commented Sep 7, 2024

You can create a dummy type to use for the annotation.

e.g.:

class ConditioningResponse(tuple):
    pass

register_type(ConditioningResponse, "CONDITIONING")


@ComfyNode()
def do_something_with_conditioning(conditioning: ConditioningResponse):
  print(conditioning)

You could get fancier and make it match the characteristics of tuple[list[list[torch.Tensor, dict]]] if you want for better type hinting, but simply doing this will give EasyNodes enough info to use 'CONDITIONING' as the input type which is all that ComfyUI needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants