Skip to content

docs: Improve --use-type-alias help text documentation#103

Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/datamodel--d07cd023
Open

docs: Improve --use-type-alias help text documentation#103
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/datamodel--d07cd023

Conversation

@staging-devin-ai-integration
Copy link

Summary

Updates the CLI help text for the --use-type-alias flag to provide clearer documentation about its functionality and limitations.

Changes

The help text for --use-type-alias has been updated from:

Use TypeAlias instead of root models (experimental)

To:

Generate Python type aliases instead of RootModel classes. Uses 'type' statement for Python 3.12+, TypeAliasType for Pydantic v2 on 3.10-3.11, and TypeAlias annotation for Pydantic v1. Note: Type aliases don't support model_config or field-specific metadata like default/alias.

Version Matrix Documentation

The updated help text now documents the following version matrix:

Pydantic Version Python Version Output Format
Pydantic v2 Python 3.12+ type Name = type (native type statement)
Pydantic v2 Python 3.10-3.11 Name = TypeAliasType("Name", type)
Pydantic v1 Python 3.10+ Name: TypeAlias = type

Limitations Documented

The help text now notes that type aliases don't support:

  • model_config configuration
  • Field-specific metadata like default, alias, etc.

Related Issues

Testing

All existing type_alias tests pass:

tests/main/jsonschema/test_main_jsonschema.py::test_main_type_alias_forward_ref_keep_model_order PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_type_alias_cycle_keep_model_order PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_type_alias PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_type_alias_py312 PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_type_alias_with_field_description PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_type_alias_with_field_description_py312 PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_type_alias_with_circular_ref_to_class_msgspec PASSED
tests/main/jsonschema/test_main_jsonschema.py::test_main_use_root_model_type_alias PASSED

Update the CLI help text for --use-type-alias flag to:
- Clarify the feature generates Python type aliases instead of RootModel classes
- Document the version matrix: 'type' statement for Python 3.12+,
  TypeAliasType for Pydantic v2 on 3.10-3.11, and TypeAlias annotation
  for Pydantic v1
- Note limitations: type aliases don't support model_config or
  field-specific metadata like default/alias

Addresses documentation requirements from issues koxudaxi#2427, koxudaxi#2018, koxudaxi#1285, koxudaxi#1848
@staging-devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants