master: docstring fixes.

This commit is contained in:
David Wilson 2018-10-26 09:12:00 +00:00
parent 8891fda48a
commit 0d04e940b7
1 changed files with 10 additions and 4 deletions

View File

@ -335,6 +335,11 @@ class LogForwarder(object):
class ModuleFinder(object): class ModuleFinder(object):
"""
Given the name of a loaded module, make a best-effort attempt at finding
related modules likely needed by a child context requesting the original
module.
"""
def __init__(self): def __init__(self):
#: Import machinery is expensive, keep :py:meth`:get_module_source` #: Import machinery is expensive, keep :py:meth`:get_module_source`
#: results around. #: results around.
@ -477,7 +482,8 @@ class ModuleFinder(object):
def resolve_relpath(self, fullname, level): def resolve_relpath(self, fullname, level):
"""Given an ImportFrom AST node, guess the prefix that should be tacked """Given an ImportFrom AST node, guess the prefix that should be tacked
on to an alias name to produce a canonical name. `fullname` is the name on to an alias name to produce a canonical name. `fullname` is the name
of the module in which the ImportFrom appears.""" of the module in which the ImportFrom appears.
"""
mod = sys.modules.get(fullname, None) mod = sys.modules.get(fullname, None)
if hasattr(mod, '__path__'): if hasattr(mod, '__path__'):
fullname += '.__init__' fullname += '.__init__'
@ -499,7 +505,7 @@ class ModuleFinder(object):
def find_related_imports(self, fullname): def find_related_imports(self, fullname):
""" """
Return a list of non-stdlb modules that are directly imported by Return a list of non-stdlib modules that are directly imported by
`fullname`, plus their parents. `fullname`, plus their parents.
The list is determined by retrieving the source code of The list is determined by retrieving the source code of
@ -550,8 +556,8 @@ class ModuleFinder(object):
Return a list of non-stdlib modules that are imported directly or Return a list of non-stdlib modules that are imported directly or
indirectly by `fullname`, plus their parents. indirectly by `fullname`, plus their parents.
This method is like :py:meth:`on_disconect`, but it also recursively This method is like :py:meth:`find_related_imports`, but also
searches any modules which are imported by `fullname`. recursively searches any modules which are imported by `fullname`.
:param fullname: Fully qualified name of an _already imported_ module :param fullname: Fully qualified name of an _already imported_ module
for which source code can be retrieved for which source code can be retrieved