maite.testing.project.get_public_symbols#
- maite.testing.project.get_public_symbols(scan, submodule='', include_dunder_names=False)[source]#
Return all public symbols (functions, classes, etc.) from a module’s API.
This function expects the results of a scan performed by
maite.testing.project.ModuleScan
, which requires thatpyright
is installed.- Parameters:
- scanModuleScanResults
The result of a scan performed by
ModuleScan.__call__
.- submodulestr, optional
If specified, only symbols from the specified submodule are included.
- include_dunder_namesbool, default=False
If
True
, then symbols like the__init__
method of public classes will be included among the public symbols.
- Returns:
- list[Symbol]
Each symbol is a dict containing the following key-value pairs:
category: Literal["class", "constant", "function", "method", "module", "symbol", "type alias", "variable"] name: str referenceCount: int isExported: bool isTypeKnown: bool isTypeAmbiguous: bool diagnostics: list[Diagnostic]
Examples
Basic usage.
>>> from maite.testing.project import get_public_symbols, ModuleScan >>> scanner = ModuleScan() >>> results = scanner("maite") >>> get_public_symbols(results) # will change as MAITE changes --> [{'category': 'class', 'name': 'maite.errors.MaiteException', 'referenceCount': 3, 'isExported': True, 'isTypeKnown': True, 'isTypeAmbiguous': False, 'diagnostics': []}, {'category': 'class', 'name': 'maite.errors.InternalError', 'referenceCount': 1, 'isExported': True, 'isTypeKnown': True, 'isTypeAmbiguous': False, 'diagnostics': []}, ...]
Accessing symbols from the
docs
submodule.>>> get_public_symbols(results, submodule="maite.testing.docs") [{'category': 'type alias', 'name': 'maite.testing.docs.NumpyDocErrorCode', 'referenceCount': 1, 'isExported': True, 'isTypeKnown': True, 'isTypeAmbiguous': False, 'diagnostics': []}, {'category': 'class', 'name': 'maite.testing.docs.NumPyDocResults', 'referenceCount': 1, 'isExported': True, 'isTypeKnown': True, 'isTypeAmbiguous': False, 'diagnostics'...