Skip to content

Conversation

@bergsalex
Copy link
Contributor

This change allows you to specify behavior params for the generate-table command using json!

if behavior_config:
try:
config = load_json(behavior_config)
if not isinstance(config, dict) or "behaviors" not in config:
Copy link
Contributor

@gbeane gbeane Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use jsonschema.validate() to validate the json (I don't think this needs to change for this pull request).

except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON in file {source}: {e}")

elif isinstance(source, str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

),
] = True,
behavior_config: Path | None = typer.Option(
None, "--behavior-config", help="JSON file with behavior configurations"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could benefit from indicating some structure of the JSON, e.g. what fields it expects and which are optional.

@bergsalex bergsalex merged commit 1a3245f into master Oct 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants