Issue #530 - Use SafeLoader for YAML load calls #532
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The primary changes address using safer version of YAML loads:
yaml.load(source,Loader=yaml.Loader)
toyaml.safe_load(source)
. (similar forload_all
)yaml.add_constructor()
toyaml.SafeLoader.add_constructor()
Then we hit a series of pre-commit errors due to newly-corrected configs which now run reorder-python-imports and black on the source code. So to satisfy those, more non-yaml updates were made. For example,
AitConfigMissing
was renamedAitConfigMissingError
.However, after a while, it became clear that black and flake8 have some contradictory rules ( e.g. 'binary logical operators across multiple lines' vs 'line-too-long' errors). In the end, we disabled checks for the binary-ops-spanning-multi-line checks in
flake8
, cuz that just seems a cleaner presentation (to me at least).So there are a lot of line changes related to the above, had I known I would have just avoided satisfying any pre-commit issues and forced the Yaml-related changes only.
flake8
would still complain about source files which weren't even touched for the PR, so in the end the pre-commit was disabled so this PR could be made without touching nearly every source file (a separate PR for that busy-work).Testing included automated tests, along with running the server with the AIT-GUI plugin and ait_example which successfully showed telemetry graphed in the browser. (Config file was reset to clear out plugins.)
Fixes #530