Skip to content

Commit

Permalink
python3-jsonschema: Fix annotation for validator_for's default
Browse files Browse the repository at this point in the history
Backport the fix, it helps some ptests on meta-python packages
e.g. pydantic

(From OE-Core rev: 08b1addfc067f864da64f6d3bfde04d8314b3249)

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
kraj authored and rpurdie committed Oct 31, 2024
1 parent ad120c0 commit 8fba1cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From d71f96a6523875c9694fcdf468c9f458323d07f2 Mon Sep 17 00:00:00 2001
From: Julian Berman <[email protected]>
Date: Thu, 17 Oct 2024 09:36:35 -0400
Subject: [PATCH] Fix the annotation for validator_for's default.

This still doesn't seem to satisfy mypy, so tell it to be quiet.

Upstream-Status: Backport [https://github.com/python-jsonschema/jsonschema/commit/d71f96a6523875c9694fcdf468c9f458323d07f2]
Signed-off-by: Khem Raj <[email protected]>
---
jsonschema/validators.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/jsonschema/validators.py b/jsonschema/validators.py
index 85c39160..b8ca3bd4 100644
--- a/jsonschema/validators.py
+++ b/jsonschema/validators.py
@@ -857,7 +857,7 @@ def extend(
version="draft2020-12",
)

-_LATEST_VERSION = Draft202012Validator
+_LATEST_VERSION: type[Validator] = Draft202012Validator


class _RefResolver:
@@ -1334,7 +1334,7 @@ def validate(instance, schema, cls=None, *args, **kwargs): # noqa: D417

def validator_for(
schema,
- default: Validator | _utils.Unset = _UNSET,
+ default: type[Validator] | _utils.Unset = _UNSET,
) -> type[Validator]:
"""
Retrieve the validator class appropriate for validating the given schema.
@@ -1396,7 +1396,7 @@ class is returned:
DefaultValidator = _LATEST_VERSION if default is _UNSET else default

if schema is True or schema is False or "$schema" not in schema:
- return DefaultValidator
+ return DefaultValidator # type: ignore[return-value]
if schema["$schema"] not in _META_SCHEMAS and default is _UNSET:
warn(
(
2 changes: 2 additions & 0 deletions meta/recipes-devtools/python/python3-jsonschema_4.23.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=7a60a81c146ec25599a3e1dabb8610a8 \
file://json/LICENSE;md5=9d4de43111d33570c8fe49b4cb0e01af"

SRC_URI += "file://d71f96a6523875c9694fcdf468c9f458323d07f2.patch"

SRC_URI[sha256sum] = "d71497fef26351a33265337fa77ffeb82423f3ea21283cd9467bb03999266bc4"

inherit pypi python_hatchling
Expand Down

0 comments on commit 8fba1cb

Please sign in to comment.