Skip to content

Commit

Permalink
Merge pull request #3077 from honno/honno/numpy-extra-proxies
Browse files Browse the repository at this point in the history
Use @proxies instead of deepcopy for mutated array helpers
  • Loading branch information
Zac-HD authored Aug 30, 2021
2 parents cbdcc7c + 203218c commit 46cf880
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RELEASE_TYPE: patch

This patch wraps some internal helper code in our proxies decorator to prevent
mutations of method docstrings carrying over to other instances of the respective
methods.
2 changes: 1 addition & 1 deletion hypothesis-python/scripts/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pip install fakeredis
$PYTEST tests/redis/
pip uninstall -y redis fakeredis

pip install typing_extensions
pip install 'typing_extensions!=3.10.0.1'
$PYTEST tests/typing_extensions/
if [ "$(python -c 'import sys; print(sys.version_info[:2] <= (3, 7))')" = "False" ] ; then
# Required by importlib_metadata backport, which we don't want to break
Expand Down
13 changes: 10 additions & 3 deletions hypothesis-python/src/hypothesis/extra/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# END HEADER

import math
from copy import deepcopy
from typing import Any, Mapping, Optional, Sequence, Tuple, Union

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


valid_tuple_axes = deepcopy(_valid_tuple_axes)
@proxies(_valid_tuple_axes)
def valid_tuple_axes(*args, **kwargs):
return _valid_tuple_axes(*args, **kwargs)


valid_tuple_axes.__doc__ = f"""
Return a strategy for generating permissible tuple-values for the
``axis`` argument for a numpy sequential function (e.g.
Expand All @@ -745,7 +748,11 @@ def nested_dtypes(
"""


mutually_broadcastable_shapes = deepcopy(_mutually_broadcastable_shapes)
@proxies(_mutually_broadcastable_shapes)
def mutually_broadcastable_shapes(*args, **kwargs):
return _mutually_broadcastable_shapes(*args, **kwargs)


mutually_broadcastable_shapes.__doc__ = f"""
{_mutually_broadcastable_shapes.__doc__}
Expand Down

0 comments on commit 46cf880

Please sign in to comment.