fix a minor type annotation bug in isdict_containingentries

This commit is contained in:
wuzhaomin 2024-05-09 14:55:10 +08:00
parent 0fedd6a1e6
commit 53b29d02a9
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From 41fac8c3bc727c0bdaa0d1b037783b759238c193 Mon Sep 17 00:00:00 2001
From: Chris Rose <offline@offby1.net>
Date: Sat, 13 Aug 2022 07:51:31 -0500
Subject: [PATCH] nit: fix a minor type annotation bug in
isdict_containingentries
Fixes #182
---
changelog.d/182.bugfix.rst | 1 +
src/hamcrest/library/collection/isdict_containingentries.py | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
create mode 100644 changelog.d/182.bugfix.rst
diff --git a/changelog.d/182.bugfix.rst b/changelog.d/182.bugfix.rst
new file mode 100644
index 0000000..1b09d8c
--- /dev/null
+++ b/changelog.d/182.bugfix.rst
@@ -0,0 +1 @@
+Use the correct generic type in the internal ``describe_keyvalue`` method
diff --git a/src/hamcrest/library/collection/isdict_containingentries.py b/src/hamcrest/library/collection/isdict_containingentries.py
index 490affa..8c17c20 100644
--- a/src/hamcrest/library/collection/isdict_containingentries.py
+++ b/src/hamcrest/library/collection/isdict_containingentries.py
@@ -57,7 +57,7 @@ class IsDictContainingEntries(BaseMatcher[Mapping[K, V]]):
def describe_mismatch(self, item: Mapping[K, V], mismatch_description: Description) -> None:
self.matches(item, mismatch_description)
- def describe_keyvalue(self, index: int, value: V, description: Description) -> None:
+ def describe_keyvalue(self, index: K, value: V, description: Description) -> None:
"""Describes key-value pair at given index."""
description.append_description_of(index).append_text(": ").append_description_of(value)
--
2.9.3.windows.1

View File

@ -1,11 +1,12 @@
Name: python-hamcrest
Version: 2.0.3
Release: 2
Release: 3
Summary: Hamcrest matchers for Python
License: BSD-3-Clause
URL: https://github.com/hamcrest/PyHamcrest
Source0: https://github.com/hamcrest/PyHamcrest/archive/V2.0.3/%{name}-%{version}.tar.gz
Patch0: numpy-1.20.0-alias-depr.patch
Patch1: backport-nit-fix-a-minor-type-annotation-bug-in-isdict_contai.patch
BuildArch: noarch
%description
@ -47,6 +48,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v
%{python3_sitelib}/*
%changelog
* Thu May 9 2024 wuzhaomin <wuzhaomin@kylinos.cn> - 2.0.3-3
- fix a minor type annotation bug in isdict_containingentries
* Sun Jul 23 2023 wangkai <13474090681@163.com> - 2.0.3-2
- Fix build error for numpy-1.20