Skip to content

Commit 930fa97

Browse files
committed
fix: use modern type format in --check option documentation example
Update test_check_file_matches to use --use-union-operator and --use-standard-collections flags so CLI docs show modern format (str | None, list) instead of deprecated Optional/List types.
1 parent 25e0f6a commit 930fa97

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

tests/data/expected/main/person.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
from __future__ import annotations
55

6-
from typing import Any, List, Optional
6+
from typing import Any
77

88
from pydantic import BaseModel, Field, conint
99

1010

1111
class Person(BaseModel):
12-
firstName: Optional[str] = Field(None, description="The person's first name.")
13-
lastName: Optional[str] = Field(None, description="The person's last name.")
14-
age: Optional[conint(ge=0)] = Field(
12+
firstName: str | None = Field(None, description="The person's first name.")
13+
lastName: str | None = Field(None, description="The person's last name.")
14+
age: conint(ge=0) | None = Field(
1515
None, description='Age in years which must be equal to or greater than zero.'
1616
)
17-
friends: Optional[List[Any]] = None
17+
friends: list[Any] | None = None
1818
comment: None = None

tests/main/test_main_general.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,9 @@ def test_skip_root_model_command_line(output_file: Path) -> None:
473473
@pytest.mark.cli_doc(
474474
options=["--check"],
475475
input_schema="jsonschema/person.json",
476-
cli_args=["--disable-timestamp", "--check"],
476+
cli_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections", "--check"],
477477
golden_output="person.py",
478+
related_options=["--use-union-operator", "--use-standard-collections"],
478479
)
479480
def test_check_file_matches(output_file: Path) -> None:
480481
"""Verify generated code matches existing output without modifying files.
@@ -488,13 +489,13 @@ def test_check_file_matches(output_file: Path) -> None:
488489
input_path=input_path,
489490
output_path=output_file,
490491
input_file_type="jsonschema",
491-
extra_args=["--disable-timestamp"],
492+
extra_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections"],
492493
)
493494
run_main_and_assert(
494495
input_path=input_path,
495496
output_path=output_file,
496497
input_file_type="jsonschema",
497-
extra_args=["--disable-timestamp", "--check"],
498+
extra_args=["--disable-timestamp", "--use-union-operator", "--use-standard-collections", "--check"],
498499
expected_exit=Exit.OK,
499500
)
500501

0 commit comments

Comments
 (0)