From bda81595704bd122718b262245391eba3a7a1e01 Mon Sep 17 00:00:00 2001 From: Raoul Schaffranek Date: Wed, 24 Sep 2025 20:38:35 +0200 Subject: [PATCH 1/3] Update ethdebug spec --- format | 2 +- generate_model.py | 42 ++++++++++++------- .../format/pointer/expression_schema.py | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/format b/format index d941a2a..f29e8a4 160000 --- a/format +++ b/format @@ -1 +1 @@ -Subproject commit d941a2aa883092411e57696dd2f1aeb8675bbc67 +Subproject commit f29e8a472e703b44b8cc64919f57a7b68eabbf2c diff --git a/generate_model.py b/generate_model.py index d7e78f9..33f62a3 100755 --- a/generate_model.py +++ b/generate_model.py @@ -1,5 +1,6 @@ from glob import glob from pathlib import Path +from tempfile import NamedTemporaryFile from datamodel_code_generator import InputFileType, generate, DataModelType from datamodel_code_generator.model import PythonVersion @@ -10,18 +11,29 @@ # Ensure output directory exists OUTPUT_DIR.mkdir(parents=True, exist_ok=True) -generate( - input_=SCHEMA_DIR, - input_file_type=InputFileType.JsonSchema, - output=OUTPUT_DIR, - output_model_type=DataModelType.PydanticV2BaseModel, - target_python_version=PythonVersion.PY_312, - allow_extra_fields=False, - disable_timestamp=True, - reuse_model=True, - use_annotated=True, - field_constraints=True, - custom_class_name_generator=lambda x: x.title().replace("Ethdebug/Format/", "").replace("/", "_"), - use_exact_imports=True, - -) +# Temporarily rename LICENSE file so it doesn't cause parsing issues +license_path = SCHEMA_DIR / "LICENSE" + +with NamedTemporaryFile() as tmp_file: + if license_path.exists(): + license_path.rename(tmp_file.name) + temp_license_path = Path(tmp_file.name) + try: + generate( + input_=SCHEMA_DIR, + input_file_type=InputFileType.JsonSchema, + output=OUTPUT_DIR, + output_model_type=DataModelType.PydanticV2BaseModel, + target_python_version=PythonVersion.PY_312, + allow_extra_fields=False, + disable_timestamp=True, + reuse_model=True, + use_annotated=True, + field_constraints=True, + custom_class_name_generator=lambda x: x.title().replace("Ethdebug/Format/", "").replace("/", "_"), + use_exact_imports=True + ) + finally: + # Restore LICENSE file + if license_path.exists(): + temp_license_path.rename(license_path) \ No newline at end of file diff --git a/src/ethdebug/format/pointer/expression_schema.py b/src/ethdebug/format/pointer/expression_schema.py index fb91018..b9e04c8 100644 --- a/src/ethdebug/format/pointer/expression_schema.py +++ b/src/ethdebug/format/pointer/expression_schema.py @@ -74,7 +74,7 @@ class Read(BaseModel): class PointerExpression( RootModel[ - Union[Literal, Variable, Constant, 'Arithmetic', Lookup, Read, 'Keccak256', 'Resize'] + Union[Literal, Variable, Constant, Arithmetic, Lookup, Read, Keccak256, Resize] ] ): root: Annotated[ From 3c7a3a08fdc4e85bf3714abcd3a2f842096d38a6 Mon Sep 17 00:00:00 2001 From: Raoul Schaffranek Date: Wed, 24 Sep 2025 20:46:16 +0200 Subject: [PATCH 2/3] Recreate LICENSE file after model generation --- generate_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate_model.py b/generate_model.py index 33f62a3..8fc52ea 100755 --- a/generate_model.py +++ b/generate_model.py @@ -14,7 +14,7 @@ # Temporarily rename LICENSE file so it doesn't cause parsing issues license_path = SCHEMA_DIR / "LICENSE" -with NamedTemporaryFile() as tmp_file: +with NamedTemporaryFile(delete=False) as tmp_file: if license_path.exists(): license_path.rename(tmp_file.name) temp_license_path = Path(tmp_file.name) @@ -35,5 +35,5 @@ ) finally: # Restore LICENSE file - if license_path.exists(): + if temp_license_path.exists(): temp_license_path.rename(license_path) \ No newline at end of file From f42d5a30697ea84f4d5f64cf693ba6d1c0d1391a Mon Sep 17 00:00:00 2001 From: Raoul Schaffranek Date: Wed, 24 Sep 2025 20:49:18 +0200 Subject: [PATCH 3/3] Patch type annotations --- src/ethdebug/format/pointer/expression_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ethdebug/format/pointer/expression_schema.py b/src/ethdebug/format/pointer/expression_schema.py index b9e04c8..fb91018 100644 --- a/src/ethdebug/format/pointer/expression_schema.py +++ b/src/ethdebug/format/pointer/expression_schema.py @@ -74,7 +74,7 @@ class Read(BaseModel): class PointerExpression( RootModel[ - Union[Literal, Variable, Constant, Arithmetic, Lookup, Read, Keccak256, Resize] + Union[Literal, Variable, Constant, 'Arithmetic', Lookup, Read, 'Keccak256', 'Resize'] ] ): root: Annotated[