Update to 4.2.0

This commit is contained in:
Karolina Surma 2021-09-21 12:05:07 +02:00
parent 9dc09b9e79
commit 8aeee581aa
8 changed files with 8 additions and 228 deletions

1
.gitignore vendored
View File

@ -32,3 +32,4 @@
/Sphinx-3.5.4.tar.gz
/Sphinx-4.0.2.tar.gz
/Sphinx-4.1.2.tar.gz
/Sphinx-4.2.0.tar.gz

View File

@ -1,35 +0,0 @@
From 648af37d864b5d76bbe833785d664e40d56d9768 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Wed, 11 Aug 2021 01:36:46 +0900
Subject: [PATCH] Fix #9537: autodoc: Some typing.* objects are broken
At the HEAD of 3.10, the implementation of `typing._GenericAlias` has
been changed to have correct _name and __name__.
---
sphinx/util/typing.py | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index f856950bf2..df5277ae7b 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -148,7 +148,9 @@ def _restify_py37(cls: Optional[Type]) -> str:
args = ', '.join(restify(a) for a in cls.__args__)
return ':obj:`~typing.Union`\\ [%s]' % args
elif inspect.isgenericalias(cls):
- if getattr(cls, '_name', None):
+ if isinstance(cls.__origin__, typing._SpecialForm):
+ text = restify(cls.__origin__) # type: ignore
+ elif getattr(cls, '_name', None):
if cls.__module__ == 'typing':
text = ':class:`~%s.%s`' % (cls.__module__, cls._name)
else:
@@ -344,7 +346,7 @@ def _stringify_py37(annotation: Any) -> str:
if not isinstance(annotation.__args__, (list, tuple)):
# broken __args__ found
pass
- elif qualname == 'Union':
+ elif qualname in ('Optional', 'Union'):
if len(annotation.__args__) > 1 and annotation.__args__[-1] is NoneType:
if len(annotation.__args__) > 2:
args = ', '.join(stringify(a) for a in annotation.__args__[:-1])

View File

@ -1,62 +0,0 @@
From 06ec5b027d01e8f7717e4687f89f335e83545ff9 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Wed, 18 Aug 2021 01:50:08 +0900
Subject: [PATCH] Fix test: Tests has been broken with pygments-2.10+
---
tests/test_intl.py | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 7791b4aeed5..e9e7ee9e24b 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -12,6 +12,7 @@
import os
import re
+import pygments
import pytest
from babel.messages import mofile, pofile
from babel.messages.catalog import Catalog
@@ -30,6 +31,8 @@
},
)
+pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))
+
def read_po(pathname):
with pathname.open() as f:
@@ -1060,8 +1063,13 @@ def test_additional_targets_should_not_be_translated(app):
assert_count(expected_expr, result, 1)
# C code block with lang should not be translated but be *C* highlighted
- expected_expr = ("""<span class="cp">#include</span> """
- """<span class="cpf">&lt;stdio.h&gt;</span>""")
+ if pygments_version < (2, 10, 0):
+ expected_expr = ("""<span class="cp">#include</span> """
+ """<span class="cpf">&lt;stdio.h&gt;</span>""")
+ else:
+ expected_expr = ("""<span class="cp">#include</span>"""
+ """<span class="w"> </span>"""
+ """<span class="cpf">&lt;stdio.h&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should not be translated
@@ -1138,8 +1146,13 @@ def test_additional_targets_should_be_translated(app):
assert_count(expected_expr, result, 1)
# C code block with lang should be translated and be *C* highlighted
- expected_expr = ("""<span class="cp">#include</span> """
- """<span class="cpf">&lt;STDIO.H&gt;</span>""")
+ if pygments_version < (2, 10, 0):
+ expected_expr = ("""<span class="cp">#include</span> """
+ """<span class="cpf">&lt;STDIO.H&gt;</span>""")
+ else:
+ expected_expr = ("""<span class="cp">#include</span>"""
+ """<span class="w"> </span>"""
+ """<span class="cpf">&lt;STDIO.H&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should be translated

View File

@ -1,36 +0,0 @@
From d0c97e9eb57126e38b7b018a101df1ecb1ad12b8 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Sat, 31 Jul 2021 01:41:35 +0900
Subject: [PATCH] Fix #9504: autodoc: generate incorrect reference to the
parent class
Autodoc generates incorrect references to the parent class the target
class inherites the class having `_name` attribute. It conciders the
parent is a kind of SpecialForm'ed class by mistake. This uses
`isinstance(X, SpecialForm)` to check that.
Note: SpecialForm became a class since Python 3.7.
---
CHANGES | 2 ++
sphinx/util/typing.py | 8 ++------
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 012d32e524..f856950bf2 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -171,12 +171,8 @@ def _restify_py37(cls: Optional[Type]) -> str:
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
return text
- elif hasattr(cls, '_name'):
- # SpecialForm
- if cls.__module__ == 'typing':
- return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
- else:
- return ':obj:`%s.%s`' % (cls.__module__, cls._name)
+ elif isinstance(cls, typing._SpecialForm):
+ return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
elif hasattr(cls, '__qualname__'):
if cls.__module__ == 'typing':
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)

View File

@ -24,11 +24,11 @@
%global upstream_name Sphinx
Name: python-sphinx
%global general_version 4.1.2
%global general_version 4.2.0
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 3%{?dist}
Release: 1%{?dist}
Epoch: 1
Summary: Python documentation generator
@ -44,23 +44,6 @@ Source0: %{pypi_source %{upstream_name} %{upstream_version}}
# Allow extra themes to exist. We pull in python3-sphinx-theme-alabaster
# which causes that test to fail.
Patch1: sphinx-test_theming.diff
# `types.Union` was renamed to `types.UnionType` on the HEAD of Python 3.10
# (refs: python/cpython#27342). Afterwars, sphinx-build crashes because of ImportError
# Merged upstream: https://github.com/sphinx-doc/sphinx/pull/9513
Patch2: rename-types-Union-to-types-UnionType.patch
# Fix test failures with python-pygments 2.10+
# https://github.com/sphinx-doc/sphinx/pull/9557
Patch3: fix-tests-with-pygments-210.patch
# Some objects under ``typing`` module are not displayed well
# with the HEAD of Python 3.10.0rc2+
# Merged upstream: https://github.com/sphinx-doc/sphinx/pull/9538
Patch4: display-typing-objects-correctly-with-Python-310.patch
# Render typing.Annotated correctly with Python 3.10
# Merged upstream: https://github.com/sphinx-doc/sphinx/pull/9590
Patch5: render-typing-Annotated-correctly-with-Python-3.10.patch
# Generate correct reference to the parent class
# Merged upstream: https://github.com/sphinx-doc/sphinx/pull/9515/
Patch6: generate-correct-reference-to-parent-class.patch
BuildArch: noarch
@ -381,6 +364,10 @@ mkdir %{buildroot}%{python3_sitelib}/sphinxcontrib
%changelog
* Fri Sep 17 2021 Karolina Surma <ksurma@redhat.com> - 1:4.2.0-1
- Update to 4.2.0
- Fixes rhbz#2003427
* Thu Sep 16 2021 Karolina Surma <ksurma@redhat.com> - 1:4.1.2-3
- Display typing objects correctly with Python 3.10 (fix FTBFS)
- Generate correct reference to parent class if class has `_name` attribute

View File

@ -1,49 +0,0 @@
From 8b2031c747e7c7e6b845ee2e3db47de617d33cc6 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Fri, 30 Jul 2021 01:27:38 +0900
Subject: [PATCH] Fix #9512: sphinx-build: crashed with the HEAD of Python 3.10
Recently, `types.Union` was renamed to `types.UnionType` on the HEAD
of 3.10 (refs: python/cpython#27342). After this change, sphinx-build
has been crashed because of ImportError.
---
sphinx/util/typing.py | 12 ++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index f1723c035a..012d32e524 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -33,10 +33,10 @@ def _evaluate(self, globalns: Dict, localns: Dict) -> Any:
ref = _ForwardRef(self.arg)
return ref._eval_type(globalns, localns)
-if sys.version_info > (3, 10):
- from types import Union as types_Union
-else:
- types_Union = None
+try:
+ from types import UnionType # type: ignore # python 3.10 or above
+except ImportError:
+ UnionType = None
if False:
# For type annotation
@@ -114,7 +114,7 @@ def restify(cls: Optional[Type]) -> str:
return ':class:`%s`' % INVALID_BUILTIN_CLASSES[cls]
elif inspect.isNewType(cls):
return ':class:`%s`' % cls.__name__
- elif types_Union and isinstance(cls, types_Union):
+ elif UnionType and isinstance(cls, UnionType):
if len(cls.__args__) > 1 and None in cls.__args__:
args = ' | '.join(restify(a) for a in cls.__args__ if a)
return 'Optional[%s]' % args
@@ -337,7 +337,7 @@ def _stringify_py37(annotation: Any) -> str:
elif hasattr(annotation, '__origin__'):
# instantiated generic provided by a user
qualname = stringify(annotation.__origin__)
- elif types_Union and isinstance(annotation, types_Union): # types.Union (for py3.10+)
+ elif UnionType and isinstance(annotation, UnionType): # types.Union (for py3.10+)
qualname = 'types.Union'
else:
# we weren't able to extract the base type, appending arguments would

View File

@ -1,26 +0,0 @@
From b82d3ef05a75b6dad9679f8746db5ef89785c7c0 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Sun, 29 Aug 2021 15:40:49 +0900
Subject: [PATCH] Fix #9589: autodoc: typing.Annotated has wrongly been
rendered
At the HEAD of 3.10, the implementation of `typing.Annotated` has
been changed to have __qualname__.
---
CHANGES | 4 ++--
sphinx/util/typing.py | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index df5277ae7b..35f808211b 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -306,6 +306,8 @@ def stringify(annotation: Any) -> str:
return 'None'
elif annotation in INVALID_BUILTIN_CLASSES:
return INVALID_BUILTIN_CLASSES[annotation]
+ elif str(annotation).startswith('typing.Annotated'): # for py310+
+ pass
elif (getattr(annotation, '__module__', None) == 'builtins' and
getattr(annotation, '__qualname__', None)):
return annotation.__qualname__

View File

@ -1 +1 @@
SHA512 (Sphinx-4.1.2.tar.gz) = 1fe998de7b8fc47989e186835748b7fb5d0b523db95434515b6af29b56d28372f2f92ab917c27cbed51aa0cad13175eda8bf4fc93a8726eb5e93e9bc6995e457
SHA512 (Sphinx-4.2.0.tar.gz) = 6c6a2424362805b758c43136a9293dcfb02d45af6e6dc2dd7ed9382f6ae04ecfbd416efeecb42219b67d026a4a0b007500e87b20d81847ab48e2ccfcdca52e75