File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ Contributors
109109* Szymon Karpinski -- intersphinx improvements
110110* \T . Powers -- HTML output improvements
111111* Taku Shimizu -- epub3 builder
112+ * Tamika Nomara -- bug fixes
112113* Thomas Lamb -- linkcheck builder
113114* Thomas Waldmann -- apidoc module fixes
114115* Till Hoffmann -- doctest option to exit after first failed test
Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ Bugs fixed
134134 Patch by Jeremy Maitin-Shepard.
135135* #13939: LaTeX: page break can separate admonition title from contents.
136136 Patch by Jean-François B.
137+ * #14004: Fix `autodoc_type_aliases ` when they appear in PEP 604 union syntax (`Alias | Type `).
138+ Patch by Tamika Nomara.
137139
138140
139141Testing
Original file line number Diff line number Diff line change @@ -616,6 +616,14 @@ def __hash__(self) -> int:
616616 def __repr__ (self ) -> str :
617617 return f'{ self .__class__ .__name__ } ({ self .name !r} )'
618618
619+ def __or__ (self , value : Any ):
620+ # When evaluating type hints, our forward ref can appear in type expressions,
621+ # i.e. `Alias | None`. It should, therefore, support `__or__` and `__ror__`.
622+ return typing .Union [self , value ]
623+
624+ def __ror__ (self , value : Any ):
625+ return typing .Union [value , self ]
626+
619627
620628class TypeAliasModule :
621629 """Pseudo module class for :confval:`autodoc_type_aliases`."""
Original file line number Diff line number Diff line change @@ -115,6 +115,14 @@ def test_TypeAliasForwardRef():
115115 sig_str = stringify_annotation (alias , 'fully-qualified-except-typing' )
116116 assert sig_str == "TypeAliasForwardRef('example') | None"
117117
118+ alias = alias | None
119+ sig_str = stringify_annotation (alias , 'fully-qualified-except-typing' )
120+ assert sig_str == "TypeAliasForwardRef('example') | None"
121+
122+ alias = None | alias
123+ sig_str = stringify_annotation (alias , 'fully-qualified-except-typing' )
124+ assert sig_str == "None | TypeAliasForwardRef('example')"
125+
118126
119127def test_TypeAliasNamespace () -> None :
120128 import logging .config
You can’t perform that action at this time.
0 commit comments