Merge pull request #7036 from tk0miya/7023_partial_listed_as_module_members

Fix #7023: autodoc: partial functions are listed as module members
This commit is contained in:
Takeshi KOMIYA 2020-01-19 23:31:15 +09:00 committed by GitHub
commit c4ed75752b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View File

@ -53,6 +53,8 @@ Bugs fixed
* #6999: napoleon: fails to parse tilde in :exc: role
* #7019: gettext: Absolute path used in message catalogs
* #7023: autodoc: nested partial functions are not listed
* #7023: autodoc: partial functions imported from other modules are listed as
module members without :impoprted-members: option
Testing
--------

View File

@ -344,10 +344,9 @@ class Documenter:
if self.options.imported_members:
return True
modname = self.get_attr(self.object, '__module__', None)
if inspect.ispartial(self.object) and modname == '_functools': # for pypy
return True
elif modname and modname != self.modname:
subject = inspect.unpartial(self.object)
modname = self.get_attr(subject, '__module__', None)
if modname and modname != self.modname:
return False
return True

View File

@ -0,0 +1 @@
from .partialfunction import func2, func3

View File

@ -1267,6 +1267,17 @@ def test_partialfunction():
]
@pytest.mark.usefixtures('setup_test')
def test_imported_partialfunction_should_not_shown_without_imported_members():
options = {"members": None}
actual = do_autodoc(app, 'module', 'target.imported_members', options)
assert list(actual) == [
'',
'.. py:module:: target.imported_members',
''
]
@pytest.mark.usefixtures('setup_test')
def test_bound_method():
options = {"members": None}