GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [3.14] annotationlib - Union '|' syntax and typing.Union[...] generate different forward references. · Issue #132805 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:While looking into #125618 I ran into this case. Using the union syntax gives a
Example: from annotationlib import get_annotations, Format from typing import Union class DifferentUnions: attrib: str | undefined other_attrib: Union[str, undefined] different_unions = get_annotations(DifferentUnions, format=Format.FORWARDREF) print(different_unions) Formatted Output: {
'attrib': ForwardRef("<class 'str'> | undefined", is_class=True, owner=<class '__main__.DifferentUnions'>),
'other_attrib': str | ForwardRef('undefined', is_class=True, owner=<class '__main__.DifferentUnions'>)
}One possible solution to this is to add a I already have a branch with this approach so I can make a PR. Doing this will break the current CPython versions tested on:CPython main branch Operating systems tested on:No response Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |