From f11c4169742f05087b6f45a7ac2dd0448cd0510c Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Fri, 20 May 2022 06:28:09 -0400 Subject: [PATCH 1/2] Fix Literal Comparison --- cppython/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppython/project.py b/cppython/project.py index 3cd2b53..72411c6 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -164,7 +164,7 @@ def write_generator_presets(path: Path, generator_name: str, toolchain_path: Pat root_preset = read_model_json(root_preset_path, CMakePresets) for include_path in root_preset.include: - if Path(include_path).name is "cppython.json": + if Path(include_path).name == "cppython.json": include_path = json_path write_model_json(root_preset_path, root_preset) From e08e62efaaa1e09fb9153e059a6ddd7627799897 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Fri, 20 May 2022 06:45:04 -0400 Subject: [PATCH 2/2] Update CMakePreset Optionals --- cppython/schema.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/cppython/schema.py b/cppython/schema.py index db2e53d..00c8b0b 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -19,10 +19,20 @@ class Preset(BaseModel): name: str hidden: Optional[bool] - inherits: list[str] = [] + inherits: Optional[list[str] | str] displayName: Optional[str] description: Optional[str] + @validator("inherits") + def validate_str(cls, values): + """ + Conform to list + """ + if isinstance(values, str): + return [values] + + return values + class ConfigurePreset(Preset): """ @@ -73,22 +83,25 @@ class CMakePresets(BaseModel, extra=Extra.forbid): """ version: int = Field(default=4, const=True) - cmakeMinimumRequired: CMakeVersion = CMakeVersion() # TODO: 'version' compatability validation - include: list[str] = [] + cmakeMinimumRequired: CMakeVersion = CMakeVersion() # TODO: 'version' compatibility validation + include: Optional[list[str]] vendor: Optional[Any] - configurePresets: list[ConfigurePreset] = [] - buildPresets: list[BuildPreset] = [] - testPresets: list[TestPreset] = [] + configurePresets: Optional[list[ConfigurePreset]] + buildPresets: Optional[list[BuildPreset]] + testPresets: Optional[list[TestPreset]] @validator("include") - def validate_path(cls, v): + def validate_path(cls, values): """ TODO """ - output = [] - for value in v: - output.append(Path(value).as_posix()) - return output + if values is not None: + output = [] + for value in values: + output.append(Path(value).as_posix()) + return output + + return None @dataclass