From 5d428e4999ed973f242bc171ae2a58044c2e34e6 Mon Sep 17 00:00:00 2001 From: whi-tw Date: Tue, 6 Sep 2022 01:27:09 +0100 Subject: [PATCH] Ignore `include` sections when validating the config (#720) * Don't validate `include` sections. We need a `continue` here because `include` sections are not 'standard', and don't have any keys to validate. `include` sections are tangentially validated later via `_include_config()`. * Move checks for non-validated sections to start Rather than looping through the whole if..elif.. block, fail fast if we're not actually going to validate the section. --- ks_includes/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ks_includes/config.py b/ks_includes/config.py index 306ceabd..aaa3184a 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -114,6 +114,10 @@ class KlipperScreenConfig: valid = True bools = strs = numbers = () for section in self.config: + if section == 'DEFAULT' or section.startswith('include '): + # Do not validate 'DEFAULT' or 'include*' sections + continue + if section == 'main': bools = ( 'invert_x', 'invert_y', 'invert_z', '24htime', 'only_heaters', 'show_cursor', 'confirm_estop', @@ -153,8 +157,6 @@ class KlipperScreenConfig: elif section.startswith('z_calibrate_position'): # This section may be deprecated in favor of moving this options under the printer section numbers = ('calibrate_x_position', 'calibrate_y_position') - elif section == 'DEFAULT': - continue else: self.errors.append(f'Section [{section}] not recognized')