Fixed errors caused by invalid config files.#1995
Merged
jensens merged 2 commits intocookiecutter:mainfrom Jan 23, 2024
alanverresen:issue1994
Merged
Fixed errors caused by invalid config files.#1995jensens merged 2 commits intocookiecutter:mainfrom alanverresen:issue1994
jensens merged 2 commits intocookiecutter:mainfrom
alanverresen:issue1994
Conversation
This commit fixes two similar errors caused by configuration files with unexpected contents: - if the config file is empty, then yaml.safe_load(stream) returns None instead of an (empty) dictionary - if the config file has an array as its top-element, then yaml.safe_load(stream) returns an array instead of a dictionary In both cases, merge_configs(default, overwrite) would raise an exception due to only expecting a dictionary as an argument. These two cases are now handled as follows: - if the config file is empty, the result is an empty dictionary resulting in the default config being used - if the config file does not have an object as its top-level element, then an exception is raised to inform the user
- rewrote name and doc of existing test for clarity - adds a test that covers the case where the YAML config file contains multiple documents - needed to add exception to linter because YAML files with multiple docs are flagged
Contributor
Author
|
Although it was not within the scope of the original issue, I added another test case that covers the case where the config file contains multiple YAML documents, because it's closely related. |
jensens
approved these changes
Jan 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a bug as described in issue #1994, and an additional bug.