From 3995b00c7c3b44c1a226bf0e9ded2a0e152511e8 Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Mon, 19 Aug 2024 14:15:28 -0700 Subject: [PATCH] feat: Add 'u' alias for QMK key width field --- keymap_drawer/keymap.py | 2 +- keymap_drawer/physical_layout.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keymap_drawer/keymap.py b/keymap_drawer/keymap.py index 3f4bcc1..65fd76f 100644 --- a/keymap_drawer/keymap.py +++ b/keymap_drawer/keymap.py @@ -6,7 +6,7 @@ from collections import defaultdict from functools import partial from itertools import chain -from typing import Iterable, Literal, Callable +from typing import Callable, Iterable, Literal from pydantic import BaseModel, Field, field_validator, model_serializer, model_validator diff --git a/keymap_drawer/physical_layout.py b/keymap_drawer/physical_layout.py index c44a1b7..54b66bf 100644 --- a/keymap_drawer/physical_layout.py +++ b/keymap_drawer/physical_layout.py @@ -17,7 +17,7 @@ import yaml from platformdirs import user_cache_dir -from pydantic import BaseModel, field_validator, model_validator +from pydantic import BaseModel, Field, field_validator, model_validator from .config import DrawConfig @@ -397,12 +397,12 @@ def generate(self, key_w: float, key_h: float, split_gap: float) -> PhysicalLayo class QmkLayout(BaseModel): """Generator for layouts given by QMK's info.json format.""" - class QmkKey(BaseModel): + class QmkKey(BaseModel, populate_by_name=True): """Model representing each key in QMK's layout definition.""" x: float # coordinates of top-left corner y: float - w: float = 1.0 + w: float = Field(default=1.0, validation_alias="u") h: float = 1.0 r: float = 0 # assume CW rotation around rx, ry (defaults to x, y), after translation to x, y rx: float | None = None