StrictFormatter#

class langchain_core.utils.formatting.StrictFormatter[source]#

Formatter that checks for extra keys.

Methods

__init__()

check_unused_args(used_args, args, kwargs)

convert_field(value, conversion)

format(format_string, /, *args, **kwargs)

format_field(value, format_spec)

get_field(field_name, args, kwargs)

get_value(key, args, kwargs)

parse(format_string)

validate_input_variables(format_string, ...)

Check that all input variables are used in the format string.

vformat(format_string, args, kwargs)

Check that no arguments are provided.

__init__()#
check_unused_args(used_args, args, kwargs)#
convert_field(value, conversion)#
format(format_string, /, *args, **kwargs)#
format_field(value, format_spec)#
get_field(field_name, args, kwargs)#
get_value(key, args, kwargs)#
parse(format_string)#
validate_input_variables(format_string: str, input_variables: list[str]) None[source]#

Check that all input variables are used in the format string.

Parameters:
  • format_string (str) – The format string.

  • input_variables (list[str]) – The input variables.

Raises:

ValueError – If any input variables are not used in the format string.

Return type:

None

vformat(format_string: str, args: Sequence, kwargs: Mapping[str, Any]) str[source]#

Check that no arguments are provided.

Parameters:
  • format_string (str) – The format string.

  • args (Sequence) – The arguments.

  • kwargs (Mapping[str, Any]) – The keyword arguments.

Returns:

The formatted string.

Raises:

ValueError – If any arguments are provided.

Return type:

str