Replace raw source strings with typed SourceInfo dataclasses#652
Conversation
...gen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java
Show resolved
Hide resolved
| Examples: region from environment, max_attempts from config file. | ||
| """ | ||
|
|
||
| name: str |
There was a problem hiding this comment.
Since we introduced the SourceName enum for type safety, this should now be str: SimpleSource.
There was a problem hiding this comment.
Its not possible to do this now due to the nature of our tests, so added a TODO.
There was a problem hiding this comment.
The point of this PR is to make sure that the source's name is one of a small number of acceptable values. If we aren't checking that those values are valid when we create the source via strict typing, the point of this PR is moot.
If we can't properly test code, sometimes that may mean that it's poorly written code. Often, it means we are either testing things that aren't valuable or we haven't thought of the right way to test them.
The tests are here to make sure that the code works, not the other way around.
| could be from different sources: {"retry_mode": "environment", "max_attempts": "config_file"} | ||
| """ | ||
|
|
||
| components: dict[str, str] |
There was a problem hiding this comment.
This should also use the new enum: dict[str, SimpleSource].
Issue #, if available:
Description of changes:
Replace raw source strings with typed SourceInfo dataclasses (SimpleSource and ComplexSource) for config source tracking. This provides structured source information and type safety across resolvers, validators, and properties.
Previously, sources were tracked as plain strings (e.g.,
"retry_mode=environment, max_attempts=config_file"). Now, simple sources useSimpleSource("environment")and complex sources useComplexSource({"retry_mode": "environment", "max_attempts": "config_file"}).Tests
The existing tests are updated to match the changed behavior and verified that all of them pass.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.