Skip to content

tdfs4ds.api_usage

tdfs4ds.api_usage

Static check of a project's tdfs4ds calls against the installed tdfs4ds.

check_api_usage(paths) reads .py files and the code cells of .ipynb notebooks, finds every call on tdfs4ds (tdfs4ds.x(...), tdfs4ds.a.b(...), import tdfs4ds as fs, from tdfs4ds.x import y) and reports the names that do not exist and the keyword arguments the function does not take. Nothing is run: the code is parsed, and only tdfs4ds itself is imported to resolve the names.

The same functions check the package's own skills (tests/test_skills_consistency.py): one rule for "does this call match tdfs4ds".

__all__ module-attribute

__all__ = ['check_api_usage', 'calls_in_tree', 'call_problems', 'resolve_dotted']

resolve_dotted

resolve_dotted(dotted: str)

The object a dotted name designates (longest importable module, then attributes). Raises AttributeError / ImportError when it does not exist.

_dotted

_dotted(node) -> Optional[str]

calls_in_tree

calls_in_tree(tree, module: str = 'tdfs4ds')

(dotted target, ast.Call) for every call on module or on a name imported from it.

call_problems

call_problems(target: str, call) -> List[str]

What is wrong with one call: an unknown name, or keywords the function does not take.

_sources

_sources(path: str)

(cell index or None, source) of a .py file or of a notebook's code cells.

_files

_files(paths) -> List[str]

check_api_usage

check_api_usage(paths, module: str = 'tdfs4ds') -> List[dict]

Every tdfs4ds call in paths (files or folders of .py / .ipynb) that does not match the installed tdfs4ds.

Returns rows {file, cell, line, name, problem} (cell = the notebook cell index, None for a .py file). An empty list means every call resolved and every keyword exists. A file that cannot be read or parsed gives one row with the reason; nothing raises. Lines starting with % or ! (notebook magics) are ignored.