diff --git a/src/app_model/_types.py b/src/app_model/_types.py index 97b293d..aede66d 100644 --- a/src/app_model/_types.py +++ b/src/app_model/_types.py @@ -57,7 +57,12 @@ class KeybindingRuleDict(TypedDict, total=False): # ------------------ commands-related types -------------------- -class Icon(BaseModel): +class _StrictModel(BaseModel): + class Config: + extra = "forbid" + + +class Icon(_StrictModel): """Icons used to represent commands, or submenus. May provide both a light and dark variant. If only one is provided, it is used @@ -87,7 +92,7 @@ def validate(cls, v: Any) -> Icon: return cls(**v) -class CommandRule(BaseModel): +class CommandRule(_StrictModel): """Data representing a command and its presentation. Presentation of contributed commands depends on the containing menu. The Command @@ -132,7 +137,7 @@ class CommandRule(BaseModel): # ------------------ keybinding-related types -------------------- -class KeybindingRule(BaseModel): +class KeybindingRule(_StrictModel): """Data representing a keybinding and when it should be active. This model lacks a corresponding command. That gets linked up elsewhere, @@ -174,7 +179,7 @@ def _bind_to_current_platform(self) -> Optional[KeyCodeStr]: # ------------------ menus-related types -------------------- -class _MenuItemBase(BaseModel): +class _MenuItemBase(_StrictModel): """Data representing where and when a menu item should be shown.""" when: Optional[context.Expr] = Field( diff --git a/tests/test_actions.py b/tests/test_actions.py index 6682572..459f065 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -23,7 +23,7 @@ dict(keybindings=[{"primary": PRIMARY_KEY}]), dict( keybindings=[ - {"primary": PRIMARY_KEY, "mac": OS_KEY, "windows": OS_KEY, "linux": OS_KEY} + {"primary": PRIMARY_KEY, "mac": OS_KEY, "win": OS_KEY, "linux": OS_KEY} ] ), dict(keybindings=[{"primary": "ctrl+a"}], menus=[{"id": MENUID}]), diff --git a/tests/test_id.py b/tests/test_id.py new file mode 100644 index 0000000..4e8cb70 --- /dev/null +++ b/tests/test_id.py @@ -0,0 +1,10 @@ +import os +import platform +import sys + + +def test_plat(): + print(f"{os.name=}") + print(f"{sys.platform=}") + print(f"{platform.system()=}") + print(f"{platform.release()=}") diff --git a/tox.ini b/tox.ini index 482d968..449e6ef 100644 --- a/tox.ini +++ b/tox.ini @@ -26,4 +26,4 @@ setenv = extras = test commands = - pytest -v --cov=app_model --cov-report=xml --color=yes --basetemp={envtmpdir} {posargs} + pytest -v -s --cov=app_model --cov-report=xml --color=yes --basetemp={envtmpdir} {posargs}