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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Setup Python
Expand All @@ -165,7 +165,9 @@ jobs:
python -m pip install hatch
- name: Lint
working-directory: ./code-gen
run: hatch fmt --check
run: |
hatch check code
hatch check fmt
- name: type-check
working-directory: ./code-gen
run: hatch run types:check
Expand Down
11 changes: 7 additions & 4 deletions code-gen/generate_data_structures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,15 @@ function (generate_data_structures TARGET_LIBRARY)
endif ()

if (GEN_DATA_OUTPUT_PYTHON)
if (NOT EXISTS ${GEN_DATA_IN_SOURCE_PATH}/${GEN_DATA_OUTPUT_PYTHON})
file (MAKE_DIRECTORY ${GEN_DATA_IN_SOURCE_PATH})
# get the parent directory of the output python file
get_filename_component (GEN_DATA_OUTPUT_PYTHON_PARENT_DIR "${GEN_DATA_IN_SOURCE_PATH}/${GEN_DATA_OUTPUT_PYTHON}" DIRECTORY)

if (NOT EXISTS "${GEN_DATA_OUTPUT_PYTHON_PARENT_DIR}")
file (MAKE_DIRECTORY "${GEN_DATA_OUTPUT_PYTHON_PARENT_DIR}")
endif ()

file (COPY ${GEN_DATA_OUTPUT_BASE_DIR}/${GEN_DATA_OUTPUT_PYTHON}
DESTINATION ${GEN_DATA_IN_SOURCE_PATH}/${GEN_DATA_OUTPUT_PYTHON}
file (COPY "${GEN_DATA_OUTPUT_BASE_DIR}/${GEN_DATA_OUTPUT_PYTHON}"
DESTINATION "${GEN_DATA_OUTPUT_PYTHON_PARENT_DIR}"
)
endif ()

Expand Down
1 change: 1 addition & 0 deletions code-gen/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ ignore = [
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
# Okay to use random
"S311",
"RUF043",
]
unfixable = [
# Don't touch unused imports
Expand Down
6 changes: 3 additions & 3 deletions code-gen/src/poly_scribe_code_gen/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def poly_scribe_code_gen() -> int:
raise RuntimeError(msg)

if args.schema:
import importlib.util
import inspect
import sys
import importlib.util # noqa: PLC0415
import inspect # noqa: PLC0415
import sys # noqa: PLC0415

module_name = "idl_module"

Expand Down
2 changes: 1 addition & 1 deletion code-gen/src/poly_scribe_code_gen/py_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _get_polymorphic_type(type_input: str, inheritance_data: dict[str, list[str]

if union_content:
union_content = [f'"{type_name}"' for type_name in union_content if type_name in defined_types]
return f"Annotated[Union[{', '.join(union_content)}],Field(discriminator=\"type\")]"
return f'Annotated[Union[{", ".join(union_content)}],Field(discriminator="type")]'

return type_input

Expand Down
Loading