Reference

Gathering module

Function to gather list of Quarto files.

gather_qmd_files Gather .qmd files from listed files/dirs, excluding specified paths.

Runner module

Functions which run tools: convert to py file, run tool, return output.

ToolRunner Run built-in and custom tools across a set of Quarto files.
lint_qmd Convert a .qmd file to .py, lint it, and clean up.
format_qmd Format Python code in a Quarto file.
temp_py_file Context manager that ensures file is removed on exit unless keep=True.

Converter modules

Code to convert Quarto (.qmd) files to Python (.py) files, preserving line alignment and extracting Python code, with both a command-line interface and callable functions.

analyse_python.analyse_block Extract metadata for a single fenced Python code block.
analyse_python.find_closing_delimiter_row Return the row number of the closing fenced-code delimiter.
analyse_python.find_content_node Get the content of the code block.
analyse_python.analyse_block_content Analyse the lines inside a fenced code block.
analyse_python.get_rows Return (row_number, line_text) pairs for a given range of rows.
analyse_python.handle_option_state_row Process a row while the parser is in the ‘chunk options’ region.
analyse_python.parse_chunk_eval Parse an eval: option from a chunk option line.
analyse_python.mark_code_row Record first code row and magic metadata.
build_output.OutputBuilder Base class for building Python output from parsed document metadata.
build_output.FormatOutputBuilder Build a formatter-friendly Python view.
build_output.LintOutputBuilder Build a lint-friendly Python view.
collect_python.collect_python_blocks Collect all fenced Python code blocks in the document.
collect_python.walk_for_python_blocks Recursively search for fenced Python code blocks.
collect_python.get_language_text Extract the language tag from a fenced code block.
converter.QmdToPyConverter Convert lines from a .qmd file to .py file.
converter.convert_qmd_to_py Convert Quarto file to Python file, preserving line alignment.
filename.get_unique_filename Generate unique path by adding “_n” before the file extension, if needed.
parse_yaml.find_metadata_node Return the YAML front matter node, if present.
parse_yaml.parse_yaml_eval_from_node Parse YAML front matter and return execute.eval setting.
rebuild_qmd.recreate_qmd_from_formatted_py Recreate a QMD file by splicing formatted Python back into its blocks.
rebuild_qmd.parse_formatted_blocks Parse formatter output into per-block Python snippets.

Linters module

Classes to check for supported and available Python linters, static type checkers, code analysis tools and code formatters on the user’s system.

ToolRegistry Registry of supported external tools.
Linters Registry of supported linters (and code analysis tools).
Formatters Registry of supported code formatters.

CLI module

Command-line interface for linting Python code in Quarto (.qmd) files, including argument parsing and orchestration of the linting workflow.

main Entry point for the lintquarto CLI.
build_parser Create and configure the CLI argument parser.
validate_args Validate command-line arguments.
validate_no_commas Check for commas in list of paths and raise ValueError if found.
parse_custom_commands Parse, validate, and warn on custom commands.
list_tools Print all supported tools and whether they’re available.

Merge module

Functions used to merge configuration settings with CLI arguments.

merge_config Merge [tool.lintquarto] config into parsed CLI args.
_merge_prefer_cli Merge a list-like option, preferring the CLI value when present.
_merge_additive Merge an additive list-like option from config and CLI.
_merge_bool_or Merge a boolean option using OR semantics.

Config module

Support for declaring lintquarto settings in a pyproject.toml configuration file.

LintquartoConfig Configuration parsed from [tool.lintquarto] in pyproject.toml.
find_pyproject_toml Walk up the directory tree to find a pyproject.toml file.
load_config Load [tool.lintquarto] settings from the nearest pyproject.toml.
_str_list Extract a list[str] from section, silently ignoring bad values.
_bool Extract a boolean from section.

Line length module

Class to detect configured line length.

LineLengthDetector Detect the configured line length for a given Python linter.

Args module

Class which extends argparse.ArgumentParser to provide user-friendly error messages and help text when incorrect command-line arguments are supplied.

CustomArgumentParser Print user-friendly error message and help text.