Skip to content

cli ¤

Module that contains the command line application.

Functions:

  • check

    Check for API breaking changes in two versions of the same package.

  • dump

    Load packages data and dump it as JSON.

  • get_parser

    Return the CLI argument parser.

  • main

    Run the main program.

check ¤

check(
    package: str | Path,
    against: str | None = None,
    against_path: str | Path | None = None,
    *,
    base_ref: str | None = None,
    extensions: (
        Sequence[
            str
            | dict[str, Any]
            | ExtensionType
            | type[ExtensionType]
        ]
        | None
    ) = None,
    search_paths: Sequence[str | Path] | None = None,
    append_sys_path: bool = False,
    find_stubs_package: bool = False,
    allow_inspection: bool = True,
    verbose: bool = False,
    color: bool | None = None,
    style: str | ExplanationStyle | None = None
) -> int

Check for API breaking changes in two versions of the same package.

Parameters:

  • package (str | Path) –

    The package to load and check.

  • against (str | None, default: None ) –

    Older Git reference (commit, branch, tag) to check against.

  • against_path (str | Path | None, default: None ) –

    Path when the "against" reference is checked out.

  • base_ref (str | None, default: None ) –

    Git reference (commit, branch, tag) to check.

  • extensions (Sequence[str | dict[str, Any] | ExtensionType | type[ExtensionType]] | None, default: None ) –

    The extensions to use.

  • search_paths (Sequence[str | Path] | None, default: None ) –

    The paths to search into.

  • append_sys_path (bool, default: False ) –

    Whether to append the contents of sys.path to the search paths.

  • allow_inspection (bool, default: True ) –

    Whether to allow inspecting modules when visiting them is not possible.

  • verbose (bool, default: False ) –

    Use a verbose output.

Returns:

  • int

    0 for success, 1 for failure.

dump ¤

dump(
    packages: Sequence[str],
    *,
    output: str | IO | None = None,
    full: bool = False,
    docstring_parser: Parser | None = None,
    docstring_options: dict[str, Any] | None = None,
    extensions: (
        Sequence[
            str
            | dict[str, Any]
            | ExtensionType
            | type[ExtensionType]
        ]
        | None
    ) = None,
    resolve_aliases: bool = False,
    resolve_implicit: bool = False,
    resolve_external: bool = False,
    search_paths: Sequence[str | Path] | None = None,
    find_stubs_package: bool = False,
    append_sys_path: bool = False,
    allow_inspection: bool = True,
    stats: bool = False
) -> int

Load packages data and dump it as JSON.

Parameters:

  • packages (Sequence[str]) –

    The packages to load and dump.

  • output (str | IO | None, default: None ) –

    Where to output the JSON-serialized data.

  • full (bool, default: False ) –

    Whether to output full or minimal data.

  • docstring_parser (Parser | None, default: None ) –

    The docstring parser to use. By default, no parsing is done.

  • docstring_options (dict[str, Any] | None, default: None ) –

    Additional docstring parsing options.

  • resolve_aliases (bool, default: False ) –

    Whether to resolve aliases (indirect objects references).

  • resolve_implicit (bool, default: False ) –

    Whether to resolve every alias or only the explicitly exported ones.

  • resolve_external (bool, default: False ) –

    Whether to load additional, unspecified modules to resolve aliases.

  • extensions (Sequence[str | dict[str, Any] | ExtensionType | type[ExtensionType]] | None, default: None ) –

    The extensions to use.

  • search_paths (Sequence[str | Path] | None, default: None ) –

    The paths to search into.

  • find_stubs_package (bool, default: False ) –

    Whether to search for stubs-only packages. If both the package and its stubs are found, they'll be merged together. If only the stubs are found, they'll be used as the package itself.

  • append_sys_path (bool, default: False ) –

    Whether to append the contents of sys.path to the search paths.

  • allow_inspection (bool, default: True ) –

    Whether to allow inspecting modules when visiting them is not possible.

  • stats (bool, default: False ) –

    Whether to compute and log stats about loading.

Returns:

  • int

    0 for success, 1 for failure.

get_parser ¤

get_parser() -> ArgumentParser

Return the CLI argument parser.

Returns:

main ¤

main(args: list[str] | None = None) -> int

Run the main program.

This function is executed when you type griffe or python -m griffe.

Parameters:

  • args (list[str] | None, default: None ) –

    Arguments passed from the command line.

Returns:

  • int

    An exit code.