From 4891bea8c52e78048396a5e604c0c478f91d90ae Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 28 Jul 2017 16:35:24 -0400 Subject: [PATCH] standardize indentation at 2 spaces Update the linter rules to require 2 spaces. Update our dumper to emit 2 spaces. Change-Id: Idef3574021845bccfc92c75425bc0f40b32b0026 Signed-off-by: Doug Hellmann --- openstack_releases/yamlutils.py | 7 +++++++ yamllint.yml | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/openstack_releases/yamlutils.py b/openstack_releases/yamlutils.py index 6442f03eaf..95c7a8e027 100644 --- a/openstack_releases/yamlutils.py +++ b/openstack_releases/yamlutils.py @@ -78,6 +78,13 @@ class PrettySafeDumper(yaml.dumper.SafeDumper): else: return super(PrettySafeDumper, self).represent_undefined(data) + # Override this method to always indent. Otherwise when a list is + # emitted, the items nested under it are not and we have inconsistent + # formatting. + # https://stackoverflow.com/questions/25108581/python-yaml-dump-bad-indentation + def increase_indent(self, flow=False, indentless=False): + return super(PrettySafeDumper, self).increase_indent(flow, False) + # NOTE(harlowja): at some point this may not be needed... # See: http://pyyaml.org/ticket/29 diff --git a/yamllint.yml b/yamllint.yml index 86d9976a83..8548bb7225 100644 --- a/yamllint.yml +++ b/yamllint.yml @@ -7,3 +7,7 @@ rules: max: 200 level: warning allow-non-breakable-words: true + + indentation: + spaces: 2 +