Skip to content

Commit a31749d

Browse files
feat: Default to native list/dict type hints instead of typing.List/Dict (#2699)
* feat: Update type hints to use standard collections (list, dict) for Python 3.10+ * docs: update CLI reference documentation 🤖 Generated by GitHub Actions * feat: Replace typing.List with built-in list and update imports for Python 3.10+ * feat: Update type hints to use frozenset and remove unnecessary imports (#2701) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 7402834 commit a31749d

272 files changed

Lines changed: 1837 additions & 1858 deletions

File tree

Some content is hidden

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

docs/cli-reference/field-customization.md

Lines changed: 88 additions & 88 deletions
Large diffs are not rendered by default.

docs/cli-reference/general-options.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
353353

354354
from __future__ import annotations
355355

356-
from typing import List, Optional
356+
from typing import Optional
357357

358358
from pydantic import BaseModel
359359

@@ -399,18 +399,18 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
399399
flavour: Optional[str] = None
400400
id: Optional[Id] = None
401401
self: Optional[Tea_1] = None
402-
optional: Optional[List[OptionalModel]] = None
402+
optional: Optional[list[OptionalModel]] = None
403403

404404

405405
class TeaClone(BaseModel):
406406
flavour: Optional[str] = None
407407
id: Optional[Id] = None
408408
self: Optional[Tea_1] = None
409-
optional: Optional[List[OptionalModel]] = None
409+
optional: Optional[list[OptionalModel]] = None
410410

411411

412-
class ListModel(BaseModel):
413-
__root__: List[Tea_1]
412+
class List(BaseModel):
413+
__root__: list[Tea_1]
414414

415415

416416
Tea_1.update_forward_refs()
@@ -434,23 +434,23 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
434434
from __future__ import annotations
435435

436436
from enum import Enum
437-
from typing import List, Optional
437+
from typing import Optional
438438

439439
from pydantic import AnyUrl, BaseModel, Field
440440

441441
from . import models
442442

443443

444444
class Pets(BaseModel):
445-
__root__: List[models.Pet]
445+
__root__: list[models.Pet]
446446

447447

448448
class Users(BaseModel):
449-
__root__: List[models.User]
449+
__root__: list[models.User]
450450

451451

452452
class Rules(BaseModel):
453-
__root__: List[str]
453+
__root__: list[str]
454454

455455

456456
class Stage(Enum):
@@ -477,7 +477,7 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
477477

478478

479479
class Apis(BaseModel):
480-
__root__: List[Api]
480+
__root__: list[Api]
481481

482482
# foo/__init__.py
483483
# generated by datamodel-codegen:
@@ -493,17 +493,17 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
493493

494494
from __future__ import annotations
495495

496-
from typing import Any, Dict, List, Optional
496+
from typing import Any, Optional
497497

498498
from pydantic import BaseModel
499499

500500

501501
class Thing(BaseModel):
502-
attributes: Optional[Dict[str, Any]] = None
502+
attributes: Optional[dict[str, Any]] = None
503503

504504

505505
class Thang(BaseModel):
506-
attributes: Optional[List[Dict[str, Any]]] = None
506+
attributes: Optional[list[dict[str, Any]]] = None
507507

508508

509509
class Others(BaseModel):
@@ -520,7 +520,7 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
520520
from __future__ import annotations
521521

522522
from enum import Enum
523-
from typing import Any, Dict, List, Optional, Union
523+
from typing import Any, Optional, Union
524524

525525
from pydantic import BaseModel
526526

@@ -545,7 +545,7 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
545545

546546

547547
class Event(BaseModel):
548-
name: Optional[Union[str, float, int, bool, Dict[str, Any], List[str]]] = None
548+
name: Optional[Union[str, float, int, bool, dict[str, Any], list[str]]] = None
549549

550550
# nested/__init__.py
551551
# generated by datamodel-codegen:
@@ -555,11 +555,11 @@ uses the complete module path. Requires `--all-exports-scope=recursive`.
555555
# generated by datamodel-codegen:
556556
# filename: modular.yaml
557557

558-
from .._internal import ListModel
558+
from .._internal import List
559559
from .._internal import Tea_1 as Tea
560560
from .._internal import TeaClone
561561

562-
__all__ = ["ListModel", "Tea", "TeaClone"]
562+
__all__ = ["List", "Tea", "TeaClone"]
563563

564564
# woo/__init__.py
565565
# generated by datamodel-codegen:
@@ -927,7 +927,7 @@ Use 'recursive' to include all descendant exports with collision handling.
927927

928928
from __future__ import annotations
929929

930-
from typing import List, Optional
930+
from typing import Optional
931931

932932
from pydantic import BaseModel
933933

@@ -973,18 +973,18 @@ Use 'recursive' to include all descendant exports with collision handling.
973973
flavour: Optional[str] = None
974974
id: Optional[Id] = None
975975
self: Optional[Tea_1] = None
976-
optional: Optional[List[OptionalModel]] = None
976+
optional: Optional[list[OptionalModel]] = None
977977

978978

979979
class TeaClone(BaseModel):
980980
flavour: Optional[str] = None
981981
id: Optional[Id] = None
982982
self: Optional[Tea_1] = None
983-
optional: Optional[List[OptionalModel]] = None
983+
optional: Optional[list[OptionalModel]] = None
984984

985985

986-
class ListModel(BaseModel):
987-
__root__: List[Tea_1]
986+
class List(BaseModel):
987+
__root__: list[Tea_1]
988988

989989

990990
Tea_1.update_forward_refs()
@@ -1008,23 +1008,23 @@ Use 'recursive' to include all descendant exports with collision handling.
10081008
from __future__ import annotations
10091009

10101010
from enum import Enum
1011-
from typing import List, Optional
1011+
from typing import Optional
10121012

10131013
from pydantic import AnyUrl, BaseModel, Field
10141014

10151015
from . import models
10161016

10171017

10181018
class Pets(BaseModel):
1019-
__root__: List[models.Pet]
1019+
__root__: list[models.Pet]
10201020

10211021

10221022
class Users(BaseModel):
1023-
__root__: List[models.User]
1023+
__root__: list[models.User]
10241024

10251025

10261026
class Rules(BaseModel):
1027-
__root__: List[str]
1027+
__root__: list[str]
10281028

10291029

10301030
class Stage(Enum):
@@ -1051,7 +1051,7 @@ Use 'recursive' to include all descendant exports with collision handling.
10511051

10521052

10531053
class Apis(BaseModel):
1054-
__root__: List[Api]
1054+
__root__: list[Api]
10551055

10561056
# foo/__init__.py
10571057
# generated by datamodel-codegen:
@@ -1067,17 +1067,17 @@ Use 'recursive' to include all descendant exports with collision handling.
10671067

10681068
from __future__ import annotations
10691069

1070-
from typing import Any, Dict, List, Optional
1070+
from typing import Any, Optional
10711071

10721072
from pydantic import BaseModel
10731073

10741074

10751075
class Thing(BaseModel):
1076-
attributes: Optional[Dict[str, Any]] = None
1076+
attributes: Optional[dict[str, Any]] = None
10771077

10781078

10791079
class Thang(BaseModel):
1080-
attributes: Optional[List[Dict[str, Any]]] = None
1080+
attributes: Optional[list[dict[str, Any]]] = None
10811081

10821082

10831083
class Others(BaseModel):
@@ -1094,7 +1094,7 @@ Use 'recursive' to include all descendant exports with collision handling.
10941094
from __future__ import annotations
10951095

10961096
from enum import Enum
1097-
from typing import Any, Dict, List, Optional, Union
1097+
from typing import Any, Optional, Union
10981098

10991099
from pydantic import BaseModel
11001100

@@ -1119,7 +1119,7 @@ Use 'recursive' to include all descendant exports with collision handling.
11191119

11201120

11211121
class Event(BaseModel):
1122-
name: Optional[Union[str, float, int, bool, Dict[str, Any], List[str]]] = None
1122+
name: Optional[Union[str, float, int, bool, dict[str, Any], list[str]]] = None
11231123

11241124
# nested/__init__.py
11251125
# generated by datamodel-codegen:
@@ -1129,11 +1129,11 @@ Use 'recursive' to include all descendant exports with collision handling.
11291129
# generated by datamodel-codegen:
11301130
# filename: modular.yaml
11311131

1132-
from .._internal import ListModel
1132+
from .._internal import List
11331133
from .._internal import Tea_1 as Tea
11341134
from .._internal import TeaClone
11351135

1136-
__all__ = ["ListModel", "Tea", "TeaClone"]
1136+
__all__ = ["List", "Tea", "TeaClone"]
11371137

11381138
# woo/__init__.py
11391139
# generated by datamodel-codegen:

docs/cli-reference/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ This documentation is auto-generated from test cases.
112112
- [`--no-alias`](field-customization.md#no-alias)
113113
- [`--no-color`](utility-options.md#no-color)
114114
- [`--no-use-specialized-enum`](typing-customization.md#no-use-specialized-enum)
115+
- [`--no-use-standard-collections`](typing-customization.md#no-use-standard-collections)
115116

116117
### O {#o}
117118

@@ -172,7 +173,6 @@ This documentation is auto-generated from test cases.
172173
- [`--use-pendulum`](typing-customization.md#use-pendulum)
173174
- [`--use-schema-description`](field-customization.md#use-schema-description)
174175
- [`--use-serialize-as-any`](model-customization.md#use-serialize-as-any)
175-
- [`--use-standard-collections`](typing-customization.md#use-standard-collections)
176176
- [`--use-status-code-in-response-name`](openapi-only-options.md#use-status-code-in-response-name)
177177
- [`--use-subclass-enum`](model-customization.md#use-subclass-enum)
178178
- [`--use-title-as-name`](field-customization.md#use-title-as-name)

0 commit comments

Comments
 (0)