formate.dynamic_quotes

Applies “dynamic quotes” to Python source code.

The rules are:

  • Use double quotes " where possible.

  • Use single quotes ' for empty strings and single characters (a, \n etc.).

  • Leave the quotes unchanged for multiline strings, f strings and raw strings.

dynamic_quotes(source)[source]

Reformats quotes in the given source, and returns the reformatted source.

Parameters

source (str) – The source to reformat.

Return type

str

Returns

The reformatted source.