Backport another patch from upstream for Python 3.9 support
This commit is contained in:
parent
7afb2d61aa
commit
23b5cdf21e
41
46372726.patch
Normal file
41
46372726.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From f236cd03e4853fd8b07a307e334c5110a78c1335 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Wieser <wieser.eric@gmail.com>
|
||||
Date: Mon, 27 Apr 2020 14:44:37 +0100
|
||||
Subject: [PATCH] Do not emit type arguments twice
|
||||
|
||||
Fixes gh-7567
|
||||
---
|
||||
sphinx/util/inspect.py | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
|
||||
index 20af75628..4977af07f 100644
|
||||
--- a/sphinx/util/inspect.py
|
||||
+++ b/sphinx/util/inspect.py
|
||||
@@ -505,8 +505,13 @@ class Signature:
|
||||
qualname = self.format_annotation(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 = self.format_annotation(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':
|
||||
@@ -519,7 +524,7 @@ class Signature:
|
||||
args = ', '.join(self.format_annotation(a) for a in annotation.__args__[:-1])
|
||||
returns = self.format_annotation(annotation.__args__[-1])
|
||||
return '%s[[%s], %s]' % (qualname, args, returns)
|
||||
- elif annotation._special:
|
||||
+ elif getattr(annotation, '_special', False):
|
||||
return qualname
|
||||
else:
|
||||
args = ', '.join(self.format_annotation(a) for a in annotation.__args__)
|
||||
--
|
||||
2.26.2
|
||||
|
@ -45,6 +45,10 @@ Patch1: sphinx-test_theming.diff
|
||||
# Backport: test: Add a docstring to avoid an error on py39a5+
|
||||
Patch2: https://github.com/sphinx-doc/sphinx/commit/ffb1ca3a.patch
|
||||
|
||||
# Backport: Do not emit type arguments twice (needed for Python 3.9)
|
||||
# Rebased from https://github.com/sphinx-doc/sphinx/commit/46372726
|
||||
Patch3: 46372726.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: python3-devel
|
||||
|
Loading…
Reference in New Issue
Block a user