From b07af9a38ab1fcf2a0dabafb556f3eecd137e574 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Sat, 28 Mar 2026 19:07:38 +0000 Subject: [PATCH] python-schema: bump to 0.7.8 Changes since 0.7.5: - Fix handling of Optional keys with default values - Improve error messages for nested schema failures - Various bug fixes and compatibility improvements Also add test.sh to verify version and data validation API. Link: https://github.com/keleshev/schema/blob/master/CHANGELOG.rst Signed-off-by: Alexandru Ardelean --- lang/python/python-schema/Makefile | 4 +-- lang/python/python-schema/test.sh | 40 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 lang/python/python-schema/test.sh diff --git a/lang/python/python-schema/Makefile b/lang/python/python-schema/Makefile index 537a32fbc1..3e9ad398d2 100644 --- a/lang/python/python-schema/Makefile +++ b/lang/python/python-schema/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=python-schema -PKG_VERSION:=0.7.5 +PKG_VERSION:=0.7.8 PKG_RELEASE:=1 PKG_MAINTAINER:=Josef Schlehofer   PYPI_NAME:=schema -PKG_HASH:=f06717112c61895cabc4707752b88716e8420a8819d71404501e114f91043197 +PKG_HASH:=e86cc08edd6fe6e2522648f4e47e3a31920a76e82cce8937535422e310862ab5 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE-MIT diff --git a/lang/python/python-schema/test.sh b/lang/python/python-schema/test.sh new file mode 100755 index 0000000000..28db068939 --- /dev/null +++ b/lang/python/python-schema/test.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +[ "$1" = "python3-schema" ] || exit 0 + +python3 - << EOF +import sys +import schema as sc + +if sc.__version__ != "$2": + print("Wrong version: " + sc.__version__) + sys.exit(1) + +from schema import Schema, SchemaError, Optional, And, Or + +# Basic type validation +s = Schema(int) +assert s.validate(42) == 42 +try: + s.validate("not an int") + sys.exit(1) +except SchemaError: + pass + +# Dict schema +s = Schema({"name": str, "age": And(int, lambda n: n > 0)}) +data = s.validate({"name": "Alice", "age": 30}) +assert data["name"] == "Alice" +assert data["age"] == 30 + +# Optional key +s = Schema({"key": str, Optional("opt"): int}) +assert s.validate({"key": "val"}) == {"key": "val"} + +# Or +s = Schema(Or(int, str)) +assert s.validate(1) == 1 +assert s.validate("x") == "x" + +sys.exit(0) +EOF