From 407c59947d169a99c19f0a686ca761c98719ff45 Mon Sep 17 00:00:00 2001 From: Koudai Aono Date: Sun, 8 Mar 2026 08:35:38 +0000 Subject: [PATCH] docs: remove final pydantic v1 references --- docs/graphql.md | 2 +- docs/llms-full.txt | 2 +- src/datamodel_code_generator/input_model.py | 2 +- src/datamodel_code_generator/model/base.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/graphql.md b/docs/graphql.md index 7dcc47851..5b4f656f3 100644 --- a/docs/graphql.md +++ b/docs/graphql.md @@ -145,7 +145,7 @@ from model import Book response = {...} books = [ - Book.parse_obj(book_raw) for book_raw in response["getAuthorBooks"] + Book.model_validate(book_raw) for book_raw in response["getAuthorBooks"] ] print(books) # [Book(author=Author(books=[], id='51341cdscwef14r13', name='J. K. Rowling', typename__='Author'), id='1321dfvrt211wdw', title='Harry Potter and the Prisoner of Azkaban', typename__='Book'), Book(author=Author(books=[], id='51341cdscwef14r13', name='J. K. Rowling', typename__='Author'), id='dvsmu12e19xmqacqw9', title='Fantastic Beasts: The Crimes of Grindelwald', typename__='Book')] diff --git a/docs/llms-full.txt b/docs/llms-full.txt index 81c2e76ce..88eee0e97 100644 --- a/docs/llms-full.txt +++ b/docs/llms-full.txt @@ -24658,7 +24658,7 @@ from model import Book response = {...} books = [ - Book.parse_obj(book_raw) for book_raw in response["getAuthorBooks"] + Book.model_validate(book_raw) for book_raw in response["getAuthorBooks"] ] print(books) # [Book(author=Author(books=[], id='51341cdscwef14r13', name='J. K. Rowling', typename__='Author'), id='1321dfvrt211wdw', title='Harry Potter and the Prisoner of Azkaban', typename__='Book'), Book(author=Author(books=[], id='51341cdscwef14r13', name='J. K. Rowling', typename__='Author'), id='dvsmu12e19xmqacqw9', title='Fantastic Beasts: The Crimes of Grindelwald', typename__='Book')] diff --git a/src/datamodel_code_generator/input_model.py b/src/datamodel_code_generator/input_model.py index d823f5a81..5ea570a0d 100644 --- a/src/datamodel_code_generator/input_model.py +++ b/src/datamodel_code_generator/input_model.py @@ -130,7 +130,7 @@ def _get_origin_name(origin: type) -> str: def _get_input_model_json_schema_class() -> type: - """Get the InputModelJsonSchema class (lazy import to avoid Pydantic v1 issues).""" + """Get the InputModelJsonSchema class lazily.""" from pydantic.json_schema import GenerateJsonSchema # noqa: PLC0415 class InputModelJsonSchema(GenerateJsonSchema): diff --git a/src/datamodel_code_generator/model/base.py b/src/datamodel_code_generator/model/base.py index 45813b636..905842de2 100644 --- a/src/datamodel_code_generator/model/base.py +++ b/src/datamodel_code_generator/model/base.py @@ -204,7 +204,7 @@ def self_reference(self) -> bool: """Check if field references its parent model. Result is cached after first call since parent is stable at render time. - Uses __dict__ for caching to avoid Pydantic v1 field assignment restrictions. + Uses __dict__ for caching to avoid Pydantic-managed field assignment. """ if "_self_reference_cache" in self.__dict__: return self.__dict__["_self_reference_cache"]