From 241be808218786ee7b684f36ea0b07846780ce50 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 26 Apr 2020 22:55:46 +0900 Subject: [PATCH 1/4] Bump to 3.0.3 final --- CHANGES | 16 ++-------------- sphinx/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/CHANGES b/CHANGES index 7e9a2c486..577d9cf82 100644 --- a/CHANGES +++ b/CHANGES @@ -1,14 +1,5 @@ -Release 3.0.3 (in development) -============================== - -Dependencies ------------- - -Incompatible changes --------------------- - -Deprecated ----------- +Release 3.0.3 (released Apr 26, 2020) +===================================== Features added -------------- @@ -21,9 +12,6 @@ Bugs fixed * #7516: autodoc: crashes if target object raises an error on accessing its attributes -Testing --------- - Release 3.0.2 (released Apr 19, 2020) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 2d860bf9d..96b1bd4ad 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -32,7 +32,7 @@ if 'PYTHONWARNINGS' not in os.environ: warnings.filterwarnings('ignore', "'U' mode is deprecated", DeprecationWarning, module='docutils.io') -__version__ = '3.0.3+' +__version__ = '3.0.3' __released__ = '3.0.3' # used when Sphinx builds its own docs #: Version info for better programmatic use. @@ -43,7 +43,7 @@ __released__ = '3.0.3' # used when Sphinx builds its own docs #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (3, 0, 3, 'beta', 0) +version_info = (3, 0, 3, 'final', 0) package_dir = path.abspath(path.dirname(__file__)) From 955ff134ba0b9495ddf63e290d7d2b76accd4b27 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 26 Apr 2020 22:56:57 +0900 Subject: [PATCH 2/4] Bump version --- CHANGES | 21 +++++++++++++++++++++ sphinx/__init__.py | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 577d9cf82..f612aa7fe 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,24 @@ +Release 3.0.4 (in development) +============================== + +Dependencies +------------ + +Incompatible changes +-------------------- + +Deprecated +---------- + +Features added +-------------- + +Bugs fixed +---------- + +Testing +-------- + Release 3.0.3 (released Apr 26, 2020) ===================================== diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 96b1bd4ad..c38491fce 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -32,8 +32,8 @@ if 'PYTHONWARNINGS' not in os.environ: warnings.filterwarnings('ignore', "'U' mode is deprecated", DeprecationWarning, module='docutils.io') -__version__ = '3.0.3' -__released__ = '3.0.3' # used when Sphinx builds its own docs +__version__ = '3.0.4+' +__released__ = '3.0.4' # used when Sphinx builds its own docs #: Version info for better programmatic use. #: @@ -43,7 +43,7 @@ __released__ = '3.0.3' # used when Sphinx builds its own docs #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (3, 0, 3, 'final', 0) +version_info = (3, 0, 4, 'beta', 0) package_dir = path.abspath(path.dirname(__file__)) From 46372726de435cbc6b70c99d95b7986f76563df4 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Mon, 27 Apr 2020 14:44:37 +0100 Subject: [PATCH 3/4] Do not emit type arguments twice Fixes gh-7567 --- sphinx/util/typing.py | 9 +++++++-- tests/test_util_typing.py | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index eb38d232c..4644b1378 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -75,8 +75,13 @@ def _stringify_py37(annotation: Any) -> str: qualname = stringify(annotation.__origin__) # ex. Union elif hasattr(annotation, '__qualname__'): qualname = '%s.%s' % (module, annotation.__qualname__) + elif hasattr(annotation, '__origin__'): + # instantiated generic provided by a user + qualname = stringify(annotation.__origin__) else: - qualname = repr(annotation) + # we weren't able to extract the base type, appending arguments would + # only make them appear twice + return repr(annotation) if getattr(annotation, '__args__', None): if qualname == 'Union': @@ -91,7 +96,7 @@ def _stringify_py37(annotation: Any) -> str: return '%s[[%s], %s]' % (qualname, args, returns) elif str(annotation).startswith('typing.Annotated'): # for py39+ return stringify(annotation.__args__[0]) - elif annotation._special: + elif getattr(annotation, '_special', False): return qualname else: args = ', '.join(stringify(a) for a in annotation.__args__) diff --git a/tests/test_util_typing.py b/tests/test_util_typing.py index f6fd35fb0..41d2a19c2 100644 --- a/tests/test_util_typing.py +++ b/tests/test_util_typing.py @@ -10,7 +10,7 @@ import sys from numbers import Integral -from typing import Any, Dict, List, TypeVar, Union, Callable, Tuple, Optional +from typing import Any, Dict, List, TypeVar, Union, Callable, Tuple, Optional, Generic import pytest @@ -24,6 +24,11 @@ class MyClass1: class MyClass2(MyClass1): __qualname__ = '' +T = TypeVar('T') + +class MyList(List[T]): + pass + def test_stringify(): assert stringify(int) == "int" @@ -42,6 +47,7 @@ def test_stringify_type_hints_containers(): assert stringify(Tuple[str, str, str]) == "Tuple[str, str, str]" assert stringify(Tuple[str, ...]) == "Tuple[str, ...]" assert stringify(List[Dict[str, Tuple]]) == "List[Dict[str, Tuple]]" + assert stringify(MyList[Tuple[int, int]]) == "test_util_typing.MyList[Tuple[int, int]]" @pytest.mark.skipif(sys.version_info < (3, 9), reason='python 3.9+ is required.') From 153682dd4c8a56d3becff70b0264df4c13b6eb41 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 28 Apr 2020 01:40:56 +0900 Subject: [PATCH 4/4] Update CHANGES for PR #7569 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index f612aa7fe..9d7886063 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #7567: autodoc: parametrized types are shown twice for generic types + Testing --------