Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ skip = ".git,*.lock,tests,docs/cli-reference,CHANGELOG.md,docs/changelog.md,docs
[tool.ty]
src.include = [ "src" ]
environment.python-version = "3.10"
rules.deprecated = "ignore"
rules.deprecated = "warn"

[tool.pytest]
ini_options.norecursedirs = [ ".hypothesis", ".tox", "tests/data/*" ]
Expand Down
4 changes: 2 additions & 2 deletions src/datamodel_code_generator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def validate_each_item(each_item: _HttpKeyValueInput) -> _HttpKeyValuePair:


@lru_cache(maxsize=1)
def _get_config_class() -> type:
def _get_config_class() -> type[Config]:
from pydantic import ConfigDict, Field, ValidationInfo, field_validator, model_validator # noqa: PLC0415
from typing_extensions import Self # noqa: PLC0415

Expand Down Expand Up @@ -1159,7 +1159,7 @@ def run_generate_from_config( # noqa: PLR0913, PLR0917
)
return generate(
input_=input_,
config=cast("Any", generation_config),
config=generation_config,
)


Expand Down
4 changes: 3 additions & 1 deletion src/datamodel_code_generator/parser/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
if TYPE_CHECKING:
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence

from typing_extensions import TypeIs

from datamodel_code_generator._types import JSONSchemaParserConfigDict
from datamodel_code_generator.config import JSONSchemaParserConfig
from datamodel_code_generator.parser.schema_version import JsonSchemaFeatures
Expand Down Expand Up @@ -3614,7 +3616,7 @@ def parse_one_of(self, name: str, obj: JsonSchemaObject, path: list[str]) -> lis
"""Parse oneOf schema into a list of data types."""
return self.parse_combined_schema(name, obj, path, "oneOf")

def _is_required_only_schema(self, item: JsonSchemaObject | bool) -> bool: # noqa: FBT001
def _is_required_only_schema(self, item: JsonSchemaObject | bool) -> TypeIs[JsonSchemaObject]: # noqa: FBT001
"""Return whether a combined-schema branch is only a property presence rule."""
if not isinstance(item, JsonSchemaObject):
return False
Expand Down
11 changes: 6 additions & 5 deletions src/datamodel_code_generator/parser/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class OpenAPIParser(JsonSchemaParser):
"""Parser for OpenAPI 2.0/3.0/3.1/3.2 and Swagger specifications."""

SCHEMA_PATHS: ClassVar[list[str]] = ["#/components/schemas"]
config: OpenAPIParserConfig

@cached_property
def schema_features(self) -> OpenAPISchemaFeatures:
Expand Down Expand Up @@ -233,11 +234,11 @@ def __init__(
if config is None and options.get("wrap_string_literal") is None:
options["wrap_string_literal"] = False
super().__init__(source=source, config=config, **options)
self.open_api_scopes: list[OpenAPIScope] = self.config.openapi_scopes or [OpenAPIScope.Schemas] # ty: ignore
self.include_path_parameters: bool = self.config.include_path_parameters # ty: ignore
self.use_status_code_in_response_name: bool = self.config.use_status_code_in_response_name # ty: ignore
self.openapi_include_paths: list[str] | None = self.config.openapi_include_paths # ty: ignore
self.openapi_include_info_version: bool = self.config.openapi_include_info_version # ty: ignore
self.open_api_scopes: list[OpenAPIScope] = self.config.openapi_scopes or [OpenAPIScope.Schemas]
self.include_path_parameters: bool = self.config.include_path_parameters
self.use_status_code_in_response_name: bool = self.config.use_status_code_in_response_name
self.openapi_include_paths: list[str] | None = self.config.openapi_include_paths
self.openapi_include_info_version: bool = self.config.openapi_include_info_version
self.openapi_info_version: str | None = None
if self.openapi_include_paths and OpenAPIScope.Paths not in self.open_api_scopes:
warn(
Expand Down
2 changes: 1 addition & 1 deletion tests/main/test_main_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def test_run_generate_from_config_generate_kwargs_are_pinned() -> None:
"""Pin the validated CLI Config values overlaid before generate() runs."""
assert _run_generate_from_config_generate_kwargs() == snapshot([
("input_", "input_"),
("config", "cast('Any', generation_config)"),
("config", "generation_config"),
])
assert _run_generate_from_config_model_copy_updates() == snapshot([
("input_filename", "None"),
Expand Down
Loading