Implement json style arguments for behaviors in generate-tables command - #46
Merged
Conversation
bergsalex
requested review from
C-1337ka,
SkepticRaven,
dahhei,
gbeane,
jacobbeierle and
keithshep
October 7, 2025 20:08
gbeane
reviewed
Oct 8, 2025
| if behavior_config: | ||
| try: | ||
| config = load_json(behavior_config) | ||
| if not isinstance(config, dict) or "behaviors" not in config: |
Contributor
There was a problem hiding this comment.
you could use jsonschema.validate() to validate the json (I don't think this needs to change for this pull request).
gbeane
reviewed
Oct 8, 2025
| except json.JSONDecodeError as e: | ||
| raise ValueError(f"Invalid JSON in file {source}: {e}") | ||
|
|
||
| elif isinstance(source, str): |
Contributor
There was a problem hiding this comment.
maybe the isinstance(source, str) block could be simplified by checking Path(source).exists() first to see if it is a path, then fall back to parsing the string as JSON and if that fails finally check if it is one of the quoted strings?
I think this could avoid the multiple attempts to open it as a file
SkepticRaven
approved these changes
Oct 8, 2025
| ), | ||
| ] = True, | ||
| behavior_config: Path | None = typer.Option( | ||
| None, "--behavior-config", help="JSON file with behavior configurations" |
Contributor
There was a problem hiding this comment.
This could benefit from indicating some structure of the JSON, e.g. what fields it expects and which are optional.
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.
This change allows you to specify behavior params for the generate-table command using json!