Skip to content

Commit 81ef088

Browse files
[pre-commit.ci] pre-commit autoupdate (#2582)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.6 → v0.14.7](astral-sh/ruff-pre-commit@v0.14.6...v0.14.7) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix variable naming in schema path iteration for clarity * Fix variable naming in schema path iteration for clarity --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
1 parent 2698818 commit 81ef088

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
- id: pyproject-fmt
1919
args: ["--max-supported-python=3.14"]
2020
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: 'v0.14.6'
21+
rev: 'v0.14.7'
2222
hooks:
2323
- id: ruff-format
2424
exclude: "^tests/data"

src/datamodel_code_generator/parser/jsonschema.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,17 +1938,18 @@ def _parse_file(
19381938
root_obj = self.SCHEMA_OBJECT_TYPE.parse_obj(raw)
19391939
self.parse_id(root_obj, path_parts)
19401940
definitions: dict[str, YamlValue] = {}
1941-
_schema_path = ""
1942-
for _schema_path, split_schema_path in self.schema_paths:
1941+
schema_path = ""
1942+
for schema_path_candidate, split_schema_path in self.schema_paths:
19431943
try:
19441944
if definitions := get_model_by_path(raw, split_schema_path):
1945+
schema_path = schema_path_candidate
19451946
break
19461947
except KeyError: # pragma: no cover
19471948
continue
19481949

19491950
for key, model in definitions.items():
19501951
obj = self.SCHEMA_OBJECT_TYPE.parse_obj(model)
1951-
self.parse_id(obj, [*path_parts, _schema_path, key])
1952+
self.parse_id(obj, [*path_parts, schema_path, key])
19521953

19531954
if object_paths:
19541955
models = get_model_by_path(raw, object_paths)
@@ -1957,7 +1958,7 @@ def _parse_file(
19571958
elif not self.skip_root_model:
19581959
self.parse_obj(obj_name, root_obj, path_parts or ["#"])
19591960
for key, model in definitions.items():
1960-
path = [*path_parts, _schema_path, key]
1961+
path = [*path_parts, schema_path, key]
19611962
reference = self.model_resolver.get(path)
19621963
if not reference or not reference.loaded:
19631964
self.parse_raw_obj(key, model, path)

0 commit comments

Comments
 (0)