Add sphinx.util.inspect:isgenericalias()

This commit is contained in:
Takeshi KOMIYA
2020-05-30 18:42:35 +09:00
parent 9988d5ce26
commit e20f29e325
3 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
from typing import List, Callable
#: A list of int
T = List[int]
C = Callable[[int], None] # a generic alias not having a doccomment

View File

@@ -560,6 +560,18 @@ def test_isproperty(app):
assert inspect.isproperty(func) is False # function
@pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required.')
@pytest.mark.sphinx(testroot='ext-autodoc')
def test_isgenericalias(app):
from target.genericalias import C, T
from target.methods import Base
assert inspect.isgenericalias(C) is True
assert inspect.isgenericalias(T) is True
assert inspect.isgenericalias(object()) is False
assert inspect.isgenericalias(Base) is False
def test_unpartial():
def func1(a, b, c):
pass