Accepting request 1101393 from home:bnavigator:branches:devel:languages:python:jupyter

- Add jupyter_events-pr80-jsonschema-referencing.patch
  * gh#jupyter/jupyter_events#80
  * Avoid test suite errors in consuming packages because of
    jsonschema DeprecationWarning
- Remove workaround for rpmlint parser crash

OBS-URL: https://build.opensuse.org/request/show/1101393
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:jupyter/python-jupyter-events?expand=0&rev=11
This commit is contained in:
Benjamin Greiner 2023-07-30 15:54:39 +00:00 committed by Git OBS Bridge
parent ef826b52a8
commit 087f36f8cc
3 changed files with 226 additions and 5 deletions

View File

@ -0,0 +1,209 @@
From d7c265b3362d68a4796f08f852745a3fd300d9ca Mon Sep 17 00:00:00 2001
From: Carlos Herrero <26092748+hbcarlos@users.noreply.github.com>
Date: Wed, 12 Jul 2023 17:58:15 +0200
Subject: [PATCH 01/15] Migrate RefResolver to referencing.Registry
---
jupyter_events/schema.py | 11 ++++++-----
jupyter_events/validators.py | 16 +++++++++++-----
pyproject.toml | 1 +
3 files changed, 18 insertions(+), 10 deletions(-)
Index: jupyter_events-0.6.3/jupyter_events/schema.py
===================================================================
--- jupyter_events-0.6.3.orig/jupyter_events/schema.py
+++ jupyter_events-0.6.3/jupyter_events/schema.py
@@ -3,7 +3,9 @@ import json
from pathlib import Path, PurePath
from typing import Optional, Type, Union
-from jsonschema import FormatChecker, RefResolver, validators
+from jsonschema import FormatChecker, validators
+from referencing import Registry
+from referencing.jsonschema import DRAFT7
try:
from jsonschema.protocols import Validator
@@ -55,8 +57,8 @@ class EventSchema:
any schema registered here follows the expected form
of Jupyter Events.
- resolver:
- RefResolver for nested JSON schema references.
+ registry:
+ Registry for nested JSON schema references.
"""
def __init__(
@@ -64,14 +66,18 @@ class EventSchema:
schema: SchemaType,
validator_class: Type[Validator] = validators.Draft7Validator, # type:ignore[assignment]
format_checker: FormatChecker = draft7_format_checker,
- resolver: Optional[RefResolver] = None,
+ registry: Optional[Registry] = None,
):
"""Initialize an event schema."""
_schema = self._load_schema(schema)
# Validate the schema against Jupyter Events metaschema.
validate_schema(_schema)
+
+ if registry is None:
+ registry = DRAFT7.create_resource(_schema) @ Registry()
+
# Create a validator for this schema
- self._validator = validator_class(_schema, resolver=resolver, format_checker=format_checker)
+ self._validator = validator_class(_schema, registry=registry, format_checker=format_checker) # type: ignore
self._schema = _schema
def __repr__(self):
Index: jupyter_events-0.6.3/jupyter_events/validators.py
===================================================================
--- jupyter_events-0.6.3.orig/jupyter_events/validators.py
+++ jupyter_events-0.6.3/jupyter_events/validators.py
@@ -2,7 +2,9 @@
import pathlib
import jsonschema
-from jsonschema import Draft7Validator, RefResolver, ValidationError
+from jsonschema import Draft7Validator, ValidationError
+from referencing import Registry
+from referencing.jsonschema import DRAFT7
draft7_format_checker = (
Draft7Validator.FORMAT_CHECKER
@@ -29,19 +31,21 @@ SCHEMA_STORE = {
EVENT_CORE_SCHEMA["$id"]: EVENT_CORE_SCHEMA,
}
-METASCHEMA_RESOLVER = RefResolver(
- base_uri=EVENT_METASCHEMA["$id"], referrer=EVENT_METASCHEMA, store=SCHEMA_STORE
-)
+resources = [
+ DRAFT7.create_resource(each)
+ for each in (EVENT_METASCHEMA, PROPERTY_METASCHEMA, EVENT_CORE_SCHEMA)
+]
+METASCHEMA_REGISTRY: Registry = resources @ Registry()
-JUPYTER_EVENTS_SCHEMA_VALIDATOR = Draft7Validator(
+JUPYTER_EVENTS_SCHEMA_VALIDATOR = Draft7Validator( # type: ignore
schema=EVENT_METASCHEMA,
- resolver=METASCHEMA_RESOLVER,
+ registry=METASCHEMA_REGISTRY,
format_checker=draft7_format_checker,
)
-JUPYTER_EVENTS_CORE_VALIDATOR = Draft7Validator(
+JUPYTER_EVENTS_CORE_VALIDATOR = Draft7Validator( # type: ignore
schema=EVENT_CORE_SCHEMA,
- resolver=METASCHEMA_RESOLVER,
+ registry=METASCHEMA_REGISTRY,
format_checker=draft7_format_checker,
)
Index: jupyter_events-0.6.3/pyproject.toml
===================================================================
--- jupyter_events-0.6.3.orig/pyproject.toml
+++ jupyter_events-0.6.3/pyproject.toml
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
name = "jupyter-events"
description = "Jupyter Event System library"
readme = "README.md"
-requires-python = ">=3.7"
+requires-python = ">=3.8"
authors = [
{ name = "Jupyter Development Team", email = "jupyter@googlegroups.com" },
]
@@ -23,7 +23,8 @@ classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
- "jsonschema[format-nongpl,format_nongpl]>=3.2.0",
+ "referencing",
+ "jsonschema[format-nongpl,format_nongpl]>=4.18.0",
"python-json-logger>=2.0.4",
"pyyaml>=5.3",
"traitlets>=5.3",
Index: jupyter_events-0.6.3/.github/workflows/python-tests.yml
===================================================================
--- jupyter_events-0.6.3.orig/.github/workflows/python-tests.yml
+++ jupyter_events-0.6.3/.github/workflows/python-tests.yml
@@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
- python-version: ["3.7", "3.11"]
+ python-version: ["3.8", "3.12"]
include:
- os: windows-latest
python-version: "3.9"
@@ -27,7 +27,7 @@ jobs:
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
- python-version: "3.8"
+ python-version: "3.11"
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
Index: jupyter_events-0.6.3/tests/test_logger.py
===================================================================
--- jupyter_events-0.6.3.orig/tests/test_logger.py
+++ jupyter_events-0.6.3/tests/test_logger.py
@@ -1,6 +1,7 @@
import io
import json
import logging
+import sys
from datetime import datetime, timedelta
from unittest.mock import MagicMock
@@ -158,12 +159,15 @@ def test_emit():
assert "__timestamp__" in event_capsule
# Remove timestamp from capsule when checking equality, since it is gonna vary
del event_capsule["__timestamp__"]
- assert event_capsule == {
+ expected = {
"__schema__": "http://test/test",
"__schema_version__": 1,
"__metadata_version__": 1,
"something": "blah",
}
+ if sys.version_info >= (3, 12):
+ expected["taskName"] = None
+ assert event_capsule == expected
def test_register_event_schema(tmp_path):
@@ -320,24 +324,30 @@ def test_unique_logger_instances():
assert "__timestamp__" in event_capsule0
# Remove timestamp from capsule when checking equality, since it is gonna vary
del event_capsule0["__timestamp__"]
- assert event_capsule0 == {
+ expected = {
"__schema__": "http://test/test0",
"__schema_version__": 1,
"__metadata_version__": 1,
"something": "blah",
}
+ if sys.version_info >= (3, 12):
+ expected["taskName"] = None
+ assert event_capsule0 == expected
event_capsule1 = json.loads(output1.getvalue())
assert "__timestamp__" in event_capsule1
# Remove timestamp from capsule when checking equality, since it is gonna vary
del event_capsule1["__timestamp__"]
- assert event_capsule1 == {
+ expected = {
"__schema__": "http://test/test1",
"__schema_version__": 1,
"__metadata_version__": 1,
"something": "blah",
}
+ if sys.version_info >= (3, 12):
+ expected["taskName"] = None
+ assert event_capsule1 == expected
def test_register_duplicate_schemas():

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Sun Jul 30 15:30:25 UTC 2023 - Ben Greiner <code@bnavigator.de>
- Add jupyter_events-pr80-jsonschema-referencing.patch
* gh#jupyter/jupyter_events#80
* Avoid test suite errors in consuming packages because of
jsonschema DeprecationWarning
- Remove workaround for rpmlint parser crash
-------------------------------------------------------------------
Wed Jul 19 20:47:32 UTC 2023 - Ben Greiner <code@bnavigator.de>

View File

@ -28,7 +28,9 @@ Summary: Jupyter Event System library
License: BSD-3-Clause
URL: https://github.com/jupyter/jupyter_events
Source: https://files.pythonhosted.org/packages/source/j/jupyter_events/jupyter_events-%{version}.tar.gz
BuildRequires: %{python_module base >= 3.7}
# PATCH-FIX-UPSTREAM jupyter_events-pr80-jsonschema-referencing.patch gh#jupyter/jupyter_events#80
Patch0: jupyter_events-pr80-jsonschema-referencing.patch
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module hatchling >= 1.5}
BuildRequires: %{python_module pip}
BuildRequires: alts
@ -36,8 +38,9 @@ BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: alts
Requires: python-PyYAML >= 5.3
Requires: python-jsonschema-format-nongpl >= 3.2.0
Requires: python-jsonschema-format-nongpl >= 4.18
Requires: python-python-json-logger >= 2.0.4
Requires: python-referencing
Requires: python-rfc3339-validator
Requires: python-rfc3986-validator >= 0.1.1
Requires: python-traitlets >= 5.3
@ -47,11 +50,12 @@ BuildArch: noarch
BuildRequires: %{python_module rfc3339-validator}
BuildRequires: %{python_module PyYAML >= 5.3}
BuildRequires: %{python_module click}
BuildRequires: %{python_module jsonschema-format-nongpl >= 3.2.0}
BuildRequires: %{python_module jsonschema-format-nongpl >= 4.18}
BuildRequires: %{python_module pytest >= 7}
BuildRequires: %{python_module pytest-asyncio >= 0.19.0}
BuildRequires: %{python_module pytest-console-scripts}
BuildRequires: %{python_module python-json-logger >= 2.0.4}
BuildRequires: %{python_module referencing}
BuildRequires: %{python_module rfc3986-validator >= 0.1.1}
BuildRequires: %{python_module rich}
BuildRequires: %{python_module traitlets >= 5.3}
@ -67,8 +71,7 @@ these events.
%prep
%autosetup -p1 -n jupyter_events-%{version}
# gh#pypa/hatch#801, gh#rpm-software-management/rpmlint#1043, gh#jupyter/jupyter_events#70
sed -i -e 's/--color=yes//' -e '/jsonschema/ s/\[.*\]//' pyproject.toml
sed -i -e 's/--color=yes//' pyproject.toml
%build
%pyproject_wheel