This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Conversation
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 41m 32s ⏱️ Results for commit 5129ea4. ♻️ This comment has been updated with latest results. |
dfangl
approved these changes
Oct 15, 2025
Member
dfangl
left a comment
There was a problem hiding this comment.
I like this! I for example was not aware of this behavior of load_file, good catch!
|
|
||
| def load_file(file_path: str, default=None, mode=None): | ||
| def load_file( | ||
| file_path: str | os.PathLike, default: Any = None, mode: str | None = None, strict: bool = False |
Member
There was a problem hiding this comment.
Suggested change
| file_path: str | os.PathLike, default: Any = None, mode: str | None = None, strict: bool = False | |
| file_path: str | os.PathLike, default: str | bytes | None = None, mode: str | None = None, strict: bool = False |
I think default should really only be str or bytes.
| def load_file(file_path: str, default=None, mode=None): | ||
| def load_file( | ||
| file_path: str | os.PathLike, default: Any = None, mode: str | None = None, strict: bool = False | ||
| ): |
Member
There was a problem hiding this comment.
Suggested change
| ): | |
| ) -> str | bytes: |
more typing 🎉
Member
There was a problem hiding this comment.
Might also be worth adding a docstring explaining default vs strict and that the latter takes precedence?
9d8416e to
836617e
Compare
836617e to
5129ea4
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Motivation
While reviewing a Pro PR I commented that
load_filemay returnNoneif the file does not exist. This behaviour may be confusing, and we should really strictly load a file, where handling the case of the missing file should be done by the caller.Changes
As a migration path, I added a
strictkwarg to the function so we can opt in to the strict behaviour. Potentially with the mind to making it strict by default in the future.In addition I migrated
deploy_cfn_templateto use this new strict mode since it is the most common source of annoyance for me.Next steps
I would like to rewrite call sites to use the strict mode to start migrating the default behaviour to be strict.