Skip to content

Commit daa85a9

Browse files
feat: Default to union operator for type hints (#2703)
* feat: Replace Optional with Union type hints for improved type clarity * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Update type hints to use Optional and Union for better compatibility * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Enhance type hinting by replacing Optional with Union and adding support for native union types * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Enhance type hinting by replacing Optional with Union and adding support for native union types * feat: Refactor type hint handling to improve union type hint generation * feat: Update type hints to use native union types and improve readability * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Update type hints to use native union types across multiple files * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Add LEGACY_BLACK_SKIP decorator to JSON Schema test functions * feat: Add LEGACY_BLACK_SKIP decorator to JSON Schema test functions * feat: Apply LEGACY_BLACK_SKIP decorator to relevant test functions * feat: Apply LEGACY_BLACK_SKIP decorator to relevant test functions * feat: Add coverage pragma to type hint method return --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1b5d3fb commit daa85a9

File tree

576 files changed

+4272
-5144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+4272
-5144
lines changed

docs/cli-reference/base-options.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ For consistent cross-platform behavior, explicitly specify `--encoding utf-8`.
6262

6363
from __future__ import annotations
6464

65-
from typing import Optional
66-
6765
from pydantic import BaseModel, Field
6866

6967

7068
class 日本語Model(BaseModel):
71-
名前: Optional[str] = Field(None, description='ユーザー名')
72-
年齢: Optional[int] = None
69+
名前: str | None = Field(None, description='ユーザー名')
70+
年齢: int | None = None
7371
```
7472

7573
---
@@ -122,15 +120,13 @@ schemas. Required unless using `--url` to fetch schema from a URL.
122120

123121
from __future__ import annotations
124122

125-
from typing import Optional
126-
127123
from pydantic import BaseModel
128124

129125

130126
class Pet(BaseModel):
131-
id: Optional[int] = None
132-
name: Optional[str] = None
133-
tag: Optional[str] = None
127+
id: int | None = None
128+
name: str | None = None
129+
tag: str | None = None
134130
```
135131

136132
---
@@ -236,15 +232,13 @@ is written to stdout.
236232

237233
from __future__ import annotations
238234

239-
from typing import Optional
240-
241235
from pydantic import BaseModel
242236

243237

244238
class Pet(BaseModel):
245-
id: Optional[int] = None
246-
name: Optional[str] = None
247-
tag: Optional[str] = None
239+
id: int | None = None
240+
name: str | None = None
241+
tag: str | None = None
248242
```
249243

250244
---
@@ -298,15 +292,13 @@ Format: `HeaderName:HeaderValue`.
298292

299293
from __future__ import annotations
300294

301-
from typing import Optional
302-
303295
from pydantic import BaseModel
304296

305297

306298
class Pet(BaseModel):
307-
id: Optional[int] = None
308-
name: Optional[str] = None
309-
tag: Optional[str] = None
299+
id: int | None = None
300+
name: str | None = None
301+
tag: str | None = None
310302
```
311303

312304
---

0 commit comments

Comments
 (0)