From 55d2805af41e285165b82c0a9dbd1dca7b123c12 Mon Sep 17 00:00:00 2001 From: Joel Lefkowitz <45922542+JoelLefkowitz@users.noreply.github.com> Date: Thu, 14 Jul 2022 17:36:26 +0100 Subject: [PATCH] Inline allow_unicode parameter --- src/drf_yasg/codecs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/drf_yasg/codecs.py b/src/drf_yasg/codecs.py index af2297ba..a5826edf 100644 --- a/src/drf_yasg/codecs.py +++ b/src/drf_yasg/codecs.py @@ -199,13 +199,13 @@ def yaml_sane_dump(data, binary): :return: the serialized YAML :rtype: str or bytes """ - encoding = None - allow_unicode = None - if binary: - encoding = 'utf-8' - allow_unicode = True return yaml.dump( - data, Dumper=SaneYamlDumper, default_flow_style=False, encoding=encoding, allow_unicode=allow_unicode) + data, + Dumper=SaneYamlDumper, + default_flow_style=False, + encoding='utf-8' if binary else None, + allow_unicode=binary + ) class SaneYamlLoader(yaml.SafeLoader):