Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-hypothesis for openSUSE:Factory checked in at 2023-11-02 20:20:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-hypothesis (Old) and /work/SRC/openSUSE:Factory/.python-hypothesis.new.17445 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-hypothesis" Thu Nov 2 20:20:47 2023 rev:69 rq:1121637 version:6.88.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-hypothesis/python-hypothesis.changes 2023-10-19 22:49:34.371335806 +0200 +++ /work/SRC/openSUSE:Factory/.python-hypothesis.new.17445/python-hypothesis.changes 2023-11-02 20:20:50.990466718 +0100 @@ -1,0 +2,8 @@ +Wed Nov 1 15:02:50 UTC 2023 - OndÅej Súkup <mimi...@gmail.com> + +- Update to 6.88.1 + * improves :func:`~hypothesis.strategies.register_type_strategy` when + used with tuple subclasses, by preventing them from being interpreted + as generic and provided to strategies like st.from_type(Sequence[int]) + +------------------------------------------------------------------- Old: ---- hypothesis-python-6.88.0.tar.gz New: ---- hypothesis-python-6.88.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-hypothesis.spec ++++++ --- /var/tmp/diff_new_pack.8Ilqif/_old 2023-11-02 20:20:51.594488943 +0100 +++ /var/tmp/diff_new_pack.8Ilqif/_new 2023-11-02 20:20:51.598489090 +0100 @@ -37,7 +37,7 @@ %endif %{?sle15_python_module_pythons} Name: python-hypothesis%{psuffix} -Version: 6.88.0 +Version: 6.88.1 Release: 0 Summary: A library for property based testing License: MPL-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.8Ilqif/_old 2023-11-02 20:20:51.638490562 +0100 +++ /var/tmp/diff_new_pack.8Ilqif/_new 2023-11-02 20:20:51.638490562 +0100 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="manual"> <param name="url">https://github.com/HypothesisWorks/hypothesis.git</param> <param name="scm">git</param> - <param name="revision">hypothesis-python-6.88.0</param> + <param name="revision">hypothesis-python-6.88.1</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">hypothesis-python-(.*)</param> <param name="subdir">hypothesis-python</param> ++++++ hypothesis-python-6.88.0.tar.gz -> hypothesis-python-6.88.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/docs/changes.rst new/hypothesis-python-6.88.1/docs/changes.rst --- old/hypothesis-python-6.88.0/docs/changes.rst 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/docs/changes.rst 2023-10-16 18:21:41.000000000 +0200 @@ -18,6 +18,16 @@ .. include:: ../RELEASE.rst +.. _v6.88.1: + +------------------- +6.88.1 - 2023-10-16 +------------------- + +This patch improves :func:`~hypothesis.strategies.register_type_strategy` when used with ``tuple`` subclasses, +by preventing them from being interpreted as generic and provided to strategies like ``st.from_type(Sequence[int])`` +(:issue:`3767`). + .. _v6.88.0: ------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/src/hypothesis/extra/django/_impl.py new/hypothesis-python-6.88.1/src/hypothesis/extra/django/_impl.py --- old/hypothesis-python-6.88.0/src/hypothesis/extra/django/_impl.py 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/src/hypothesis/extra/django/_impl.py 2023-10-16 18:21:41.000000000 +0200 @@ -11,7 +11,7 @@ import sys import unittest from functools import partial -from typing import TYPE_CHECKING, Optional, Type, Union +from typing import TYPE_CHECKING, Optional, Type, TypeVar, Union from django import forms as df, test as dt from django.contrib.staticfiles import testing as dst @@ -30,6 +30,8 @@ else: EllipsisType = type(Ellipsis) +ModelT = TypeVar("ModelT", bound=dm.Model) + class HypothesisTestCase: def setup_example(self): @@ -64,8 +66,8 @@ @defines_strategy() def from_model( - model: Type[dm.Model], /, **field_strategies: Union[st.SearchStrategy, EllipsisType] -) -> st.SearchStrategy: + model: Type[ModelT], /, **field_strategies: Union[st.SearchStrategy, EllipsisType] +) -> st.SearchStrategy[ModelT]: """Return a strategy for examples of ``model``. .. warning:: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/src/hypothesis/strategies/_internal/types.py new/hypothesis-python-6.88.1/src/hypothesis/strategies/_internal/types.py --- old/hypothesis-python-6.88.0/src/hypothesis/strategies/_internal/types.py 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/src/hypothesis/strategies/_internal/types.py 2023-10-16 18:21:41.000000000 +0200 @@ -391,10 +391,16 @@ for k, v in _global_type_lookup.items() if is_generic_type(k) and try_issubclass(k, thing) } - # Drop some unusual cases for simplicity - for weird in (tuple, getattr(os, "_Environ", None)): - if len(mapping) > 1: - mapping.pop(weird, None) + # Drop some unusual cases for simplicity, including tuples or its + # subclasses (e.g. namedtuple) + if len(mapping) > 1: + _Environ = getattr(os, "_Environ", None) + mapping.pop(_Environ, None) + tuple_types = [t for t in mapping if isinstance(t, type) and issubclass(t, tuple)] + if len(mapping) > len(tuple_types): + for tuple_type in tuple_types: + mapping.pop(tuple_type) + # After we drop Python 3.8 and can rely on having generic builtin types, we'll # be able to simplify this logic by dropping the typing-module handling. if {dict, set, typing.Dict, typing.Set}.intersection(mapping): @@ -407,6 +413,7 @@ # the ghostwriter than it's worth, via undefined names in the repr. mapping.pop(collections.deque, None) mapping.pop(typing.Deque, None) + if len(mapping) > 1: # issubclass treats bytestring as a kind of sequence, which it is, # but treating it as such breaks everything else when it is presumed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/src/hypothesis/version.py new/hypothesis-python-6.88.1/src/hypothesis/version.py --- old/hypothesis-python-6.88.0/src/hypothesis/version.py 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/src/hypothesis/version.py 2023-10-16 18:21:41.000000000 +0200 @@ -8,5 +8,5 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at https://mozilla.org/MPL/2.0/. -__version_info__ = (6, 88, 0) +__version_info__ = (6, 88, 1) __version__ = ".".join(map(str, __version_info__)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/tests/cover/test_lookup.py new/hypothesis-python-6.88.1/tests/cover/test_lookup.py --- old/hypothesis-python-6.88.0/tests/cover/test_lookup.py 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/tests/cover/test_lookup.py 2023-10-16 18:21:41.000000000 +0200 @@ -36,7 +36,12 @@ from hypothesis.strategies import from_type from hypothesis.strategies._internal import types -from tests.common.debug import assert_all_examples, find_any, minimal +from tests.common.debug import ( + assert_all_examples, + assert_no_examples, + find_any, + minimal, +) from tests.common.utils import fails_with, temp_registered sentinel = object() @@ -1146,6 +1151,17 @@ st.builds(f).example() +class TupleSubtype(tuple): + pass + + +def test_tuple_subclasses_not_generic_sequences(): + # see https://github.com/HypothesisWorks/hypothesis/issues/3767. + with temp_registered(TupleSubtype, st.builds(TupleSubtype)): + s = st.from_type(typing.Sequence[int]) + assert_no_examples(s, lambda x: isinstance(x, tuple)) + + def test_custom_strategy_function_resolves_types_conditionally(): sentinel = object() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hypothesis-python-6.88.0/tests/cover/test_lookup_py39.py new/hypothesis-python-6.88.1/tests/cover/test_lookup_py39.py --- old/hypothesis-python-6.88.0/tests/cover/test_lookup_py39.py 2023-10-16 00:23:14.000000000 +0200 +++ new/hypothesis-python-6.88.1/tests/cover/test_lookup_py39.py 2023-10-16 18:21:41.000000000 +0200 @@ -125,3 +125,27 @@ st.from_type(list[int]), lambda ls: len(ls) <= 2 and {type(x) for x in ls}.issubset({int}), ) + + +T = typing.TypeVar("T") + + +@typing.runtime_checkable +class Fooable(typing.Protocol[T]): + def foo(self): + ... + + +class FooableConcrete(tuple): + def foo(self): + pass + + +def test_only_tuple_subclasses_in_typing_type(): + # A generic typing type (such as Fooable) whose only concrete + # instantiations are tuples should still generate tuples. This is in + # contrast to test_tuple_subclasses_not_generic_sequences, which discards + # tuples if there are any alternatives. + with temp_registered(FooableConcrete, st.builds(FooableConcrete)): + s = st.from_type(Fooable[int]) + assert_all_examples(s, lambda x: type(x) is FooableConcrete)