API
The main entrypoint for running PythonTA’s code analysis is the check_all
function.
- python_ta.check_all(module_name: list[str] | str = '', config: dict[str, Any] | str = '', output: str | None = None, load_default_config: bool = True, autoformat: bool | None = False) PythonTaReporter
Analyse one or more Python modules for code issues and display the results.
- Parameters:
module_name – If an empty string (default), the module where this function is called is checked. If a non-empty string, it is interpreted as a path to a single Python module or a directory containing Python modules. If the latter, all Python modules in the directory are checked. If a list of strings, each string is interpreted as a path to a module or directory, and all modules across all paths are checked.
config – If a string, a path to a configuration file to use. If a dictionary, a map of configuration options (each key is the name of an option).
output – If provided, the PythonTA report is written to this path. Otherwise, the report is written to standard out or automatically displayed in a web browser, depending on which reporter is used.
load_default_config – If True (default), additional configuration passed with the
config
option is merged with the default PythonTA configuration file. If False, the default PythonTA configuration is not used.autoformat – If True, autoformat all modules using the black formatting tool before analyzing code.
- Returns:
The
PythonTaReporter
object that generated the report.
Notes:
For information on using the
config
argument, see Configuration.If using the
ColorReporter
, writing to a file using theoutput
argument is not recommended. This reporter uses terminal-specific characters to colourize text displayed on your screen, and these characters will look strange when opening the output file in a text editor.
The doc
function can be used to open the PythonTA Checks webpage to look up a specific error.
- python_ta.doc(msg_id: str) None
Open the PythonTA documentation page for the given error message id.
- Parameters:
msg_id – The five-character error code, e.g.
"E0401"
.