ITADN

Fix Python 3.14 compatibility for typing.Union annotations

#2093Pull Requestfrenzymadness 创建于 2026-03-09
F
frenzymadnesscommented
In Python 3.14, typing.Union changed its repr from 'typing.Union[X, Y]' to 'X | Y' (PEP 604), breaking annotation inference. Changes: - Use getattr() instead of safe_getattr() for __module__ retrieval (getattr_static fails on Union types in Python 3.14) - Add fallback to typing.get_origin() when regex fails to match - Normalize Union display back to 'Union[X, Y]' format for consistency - Update test expectations for invalid annotation edge case in 3.14 Fixes: https://github.com/davidhalter/jedi/issues/2064 It works for me on Python 3.12, 3.13, and 3.14.
合并状态:未合并 2 条评论