From 01dc123ea138f31491c8ad32cace056330e0de08 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 1 May 2026 16:33:24 +0200 Subject: [PATCH] Allow unions when inferring annotations --- jedi/inference/gradual/annotation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index 51dc5460..957ec660 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -32,9 +32,9 @@ def infer_annotation(context, annotation): Also checks for forward references (strings) """ value_set = context.infer_node(annotation) - if len(value_set) != 1: - debug.warning("Inferred typing index %s should lead to 1 object, " - " not %s" % (annotation, value_set)) + if len(value_set) == 0: + debug.warning( + "Inferred typing index %s should lead to 1 object, not %s" % (annotation, value_set)) return value_set inferred_value = list(value_set)[0]