Skip to content

Commit 46cf880

Browse files
authored
Merge pull request #3077 from honno/honno/numpy-extra-proxies
Use @proxies instead of deepcopy for mutated array helpers
2 parents cbdcc7c + 203218c commit 46cf880

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎hypothesis-python/RELEASE.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RELEASE_TYPE: patch
2+
3+
This patch wraps some internal helper code in our proxies decorator to prevent
4+
mutations of method docstrings carrying over to other instances of the respective
5+
methods.

‎hypothesis-python/scripts/basic-test.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pip install fakeredis
3131
$PYTEST tests/redis/
3232
pip uninstall -y redis fakeredis
3333

34-
pip install typing_extensions
34+
pip install 'typing_extensions!=3.10.0.1'
3535
$PYTEST tests/typing_extensions/
3636
if [ "$(python -c 'import sys; print(sys.version_info[:2] <= (3, 7))')" = "False" ] ; then
3737
# Required by importlib_metadata backport, which we don't want to break

‎hypothesis-python/src/hypothesis/extra/numpy.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# END HEADER
1515

1616
import math
17-
from copy import deepcopy
1817
from typing import Any, Mapping, Optional, Sequence, Tuple, Union
1918

2019
import numpy as np
@@ -734,7 +733,11 @@ def nested_dtypes(
734733
).filter(lambda d: max_itemsize is None or d.itemsize <= max_itemsize)
735734

736735

737-
valid_tuple_axes = deepcopy(_valid_tuple_axes)
736+
@proxies(_valid_tuple_axes)
737+
def valid_tuple_axes(*args, **kwargs):
738+
return _valid_tuple_axes(*args, **kwargs)
739+
740+
738741
valid_tuple_axes.__doc__ = f"""
739742
Return a strategy for generating permissible tuple-values for the
740743
``axis`` argument for a numpy sequential function (e.g.
@@ -745,7 +748,11 @@ def nested_dtypes(
745748
"""
746749

747750

748-
mutually_broadcastable_shapes = deepcopy(_mutually_broadcastable_shapes)
751+
@proxies(_mutually_broadcastable_shapes)
752+
def mutually_broadcastable_shapes(*args, **kwargs):
753+
return _mutually_broadcastable_shapes(*args, **kwargs)
754+
755+
749756
mutually_broadcastable_shapes.__doc__ = f"""
750757
{_mutually_broadcastable_shapes.__doc__}
751758

0 commit comments

Comments
 (0)