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.
This commit is contained in:
whi-tw 2022-09-06 01:27:09 +01:00 committed by GitHub
parent abe12cca30
commit 5d428e4999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')