Skip to content

Commit

Permalink
Merge pull request #2610 from HypothesisWorks/pyup-scheduled-update-2…
Browse files Browse the repository at this point in the history
…020-09-07
  • Loading branch information
Zac-HD authored Sep 21, 2020
2 parents ea0a0c3 + 7f59190 commit c8d9262
Show file tree
Hide file tree
Showing 41 changed files with 186 additions and 146 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python
python: "3.6"
python: "3.8"

os:
- linux
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
- stage: precheck
env: TASK=check-whole-repo-tests
- env: TASK=lint
- env: TASK=check-py36
- env: TASK=check-py38
- stage: deploy
env: TASK=deploy

Expand Down
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
versionSpec: '3.8'
- script: sudo apt-get update && sudo apt-get install libreadline-dev libsqlite3-dev shellcheck
displayName: Install apt dependencies
- script: ./build.sh check-installed
Expand All @@ -47,10 +47,10 @@ jobs:
strategy:
matrix:
check-py36-x64:
python.version: '3.6'
python.version: '3.8'
python.architecture: 'x64'
check-py36-x86:
python.version: '3.6'
python.version: '3.8'
python.architecture: 'x86'
steps:
- task: UsePythonVersion@0
Expand All @@ -77,7 +77,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
versionSpec: '3.8'
- script: |
brew update
brew install readline xz ncurses
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
versionSpec: '3.8'
- script: sudo apt-get update && sudo apt-get install libreadline-dev libsqlite3-dev shellcheck
displayName: Install apt dependencies
- script: ./build.sh check-installed
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ elif [ -n "${TRAVIS-}" ] ; then
PYTHON=$(command -v python)
else
# Otherwise, we install it from scratch
"$SCRIPTS/ensure-python.sh" 3.6.8
PYTHON=$(pythonloc 3.6.8)/bin/python
"$SCRIPTS/ensure-python.sh" 3.8.5
PYTHON=$(pythonloc 3.8.5)/bin/python
fi

TOOL_REQUIREMENTS="$ROOT/requirements/tools.txt"
Expand Down
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This patch reformats our code with the latest :pypi:`black` to
take advantage of the support for magic trailing commas.
2 changes: 1 addition & 1 deletion hypothesis-python/scripts/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if [ "$(python -c 'import sys, platform; print(sys.version_info[:2] >= (3, 6) an
pip uninstall -y black numpy
fi

if [ "$(python -c 'import sys; print(sys.version_info[:2] == (3, 6))')" = "False" ] ; then
if [ "$(python -c 'import sys; print(sys.version_info[:2] == (3, 8))')" = "False" ] ; then
exit 0
fi

Expand Down
4 changes: 3 additions & 1 deletion hypothesis-python/src/hypothesis/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ def show_changed(self):

@staticmethod
def register_profile(
name: str, parent: Optional["settings"] = None, **kwargs: Any,
name: str,
parent: Optional["settings"] = None,
**kwargs: Any,
) -> None:
"""Registers a collection of values to be used as a settings profile.
Expand Down
4 changes: 2 additions & 2 deletions hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ def fuzz_one_input(

def given(
*_given_arguments: Union[SearchStrategy, InferType],
**_given_kwargs: Union[SearchStrategy, InferType]
**_given_kwargs: Union[SearchStrategy, InferType],
) -> Callable[[Callable[..., None]], Callable[..., None]]:
"""A decorator for turning a test function that accepts arguments into a
randomized test.
Expand Down Expand Up @@ -1225,7 +1225,7 @@ def find(
*,
settings: Optional[Settings] = None,
random: Optional[Random] = None,
database_key: Optional[bytes] = None
database_key: Optional[bytes] = None,
) -> Ex:
"""Returns the minimal example from the given strategy ``specifier`` that
matches the predicate function ``condition``."""
Expand Down
3 changes: 2 additions & 1 deletion hypothesis-python/src/hypothesis/extra/django/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
} # type: Dict[Type[AnyField], Union[st.SearchStrategy, Callable[[Any], st.SearchStrategy]]]

_ipv6_strings = st.one_of(
st.ip_addresses(v=6).map(str), st.ip_addresses(v=6).map(lambda addr: addr.exploded),
st.ip_addresses(v=6).map(str),
st.ip_addresses(v=6).map(lambda addr: addr.exploded),
)


Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/extra/django/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _models_impl(draw, strat):
def from_form(
form: Type[df.Form],
form_kwargs: Optional[dict] = None,
**field_strategies: Union[st.SearchStrategy, InferType]
**field_strategies: Union[st.SearchStrategy, InferType],
) -> st.SearchStrategy[df.Form]:
"""Return a strategy for examples of ``form``.
Expand Down
5 changes: 4 additions & 1 deletion hypothesis-python/src/hypothesis/extra/ghostwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,10 @@ def _make_binop_body(
parts = []

def maker(
sub_property: str, args: str, body: str, right: Optional[str] = None,
sub_property: str,
args: str,
body: str,
right: Optional[str] = None,
) -> None:
if right is not None:
body = f"left={body}\nright={right}\n" + _assert_eq(style, "left", "right")
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/extra/lark.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def from_lark(
grammar: lark.lark.Lark,
*,
start: Optional[str] = None,
explicit: Optional[Dict[str, st.SearchStrategy[str]]] = None
explicit: Optional[Dict[str, st.SearchStrategy[str]]] = None,
) -> st.SearchStrategy[str]:
"""A strategy for strings accepted by the given context-free grammar.
Expand Down
40 changes: 22 additions & 18 deletions hypothesis-python/src/hypothesis/extra/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
Shape = Tuple[int, ...]
# flake8 and mypy disagree about `ellipsis` (the type of `...`), and hence:
BasicIndex = Tuple[Union[int, slice, "ellipsis", np.newaxis], ...] # noqa: F821
BroadcastableShapes = NamedTuple(
"BroadcastableShapes",
[("input_shapes", Tuple[Shape, ...]), ("result_shape", Shape)],
)

TIME_RESOLUTIONS = tuple("Y M D h m s ms us ns ps fs as".split())


class BroadcastableShapes(NamedTuple):
input_shapes: Tuple[Shape, ...]
result_shape: Shape


@st.defines_strategy(force_reusable_values=True)
def from_dtype(dtype: np.dtype) -> st.SearchStrategy[Any]:
"""Creates a strategy which can generate any value of the given dtype."""
Expand Down Expand Up @@ -96,7 +96,7 @@ def from_dtype(dtype: np.dtype) -> st.SearchStrategy[Any]:
res = st.sampled_from(TIME_RESOLUTIONS)
result = st.builds(dtype.type, st.integers(-(2 ** 63), 2 ** 63 - 1), res)
else:
raise InvalidArgument("No strategy inference for {}".format(dtype))
raise InvalidArgument(f"No strategy inference for {dtype}")
return result.map(dtype.type)


Expand Down Expand Up @@ -305,7 +305,7 @@ def arrays(
*,
elements: Optional[st.SearchStrategy[Any]] = None,
fill: Optional[st.SearchStrategy[Any]] = None,
unique: bool = False
unique: bool = False,
) -> st.SearchStrategy[np.ndarray]:
r"""Returns a strategy for generating :class:`numpy:numpy.ndarray`\ s.
Expand Down Expand Up @@ -677,7 +677,7 @@ def array_dtypes(
*,
min_size: int = 1,
max_size: int = 5,
allow_subarrays: bool = False
allow_subarrays: bool = False,
) -> st.SearchStrategy[np.dtype]:
"""Return a strategy for generating array (compound) dtypes, with members
drawn from the given subtype strategy."""
Expand Down Expand Up @@ -713,7 +713,7 @@ def nested_dtypes(
subtype_strategy: st.SearchStrategy[np.dtype] = scalar_dtypes(),
*,
max_leaves: int = 10,
max_itemsize: Optional[int] = None
max_itemsize: Optional[int] = None,
) -> st.SearchStrategy[np.dtype]:
"""Return the most-general dtype strategy.
Expand All @@ -733,7 +733,10 @@ def nested_dtypes(
@st.defines_strategy()
@deprecated_posargs
def valid_tuple_axes(
ndim: int, *, min_size: int = 0, max_size: Optional[int] = None,
ndim: int,
*,
min_size: int = 0,
max_size: Optional[int] = None,
) -> st.SearchStrategy[Shape]:
"""Return a strategy for generating permissible tuple-values for the
``axis`` argument for a numpy sequential function (e.g.
Expand Down Expand Up @@ -787,7 +790,7 @@ def broadcastable_shapes(
min_dims: int = 0,
max_dims: Optional[int] = None,
min_side: int = 1,
max_side: Optional[int] = None
max_side: Optional[int] = None,
) -> st.SearchStrategy[Shape]:
"""Return a strategy for generating shapes that are broadcast-compatible
with the provided shape.
Expand Down Expand Up @@ -1037,12 +1040,13 @@ def _draw_loop_dimensions(self, data, use=None):
_DIMENSION = r"\w+\??" # Note that \w permits digits too!
_SHAPE = r"\((?:{0}(?:,{0})".format(_DIMENSION) + r"{0,31})?\)"
_ARGUMENT_LIST = "{0}(?:,{0})*".format(_SHAPE)
_SIGNATURE = r"^{}->{}$".format(_ARGUMENT_LIST, _SHAPE)
_SIGNATURE = fr"^{_ARGUMENT_LIST}->{_SHAPE}$"
_SIGNATURE_MULTIPLE_OUTPUT = r"^{0}->{0}$".format(_ARGUMENT_LIST)

_GUfuncSig = NamedTuple(
"_GUfuncSig", [("input_shapes", Tuple[Shape, ...]), ("result_shape", Shape)]
)

class _GUfuncSig(NamedTuple):
input_shapes: Tuple[Shape, ...]
result_shape: Shape


def _hypothesis_parse_gufunc_signature(signature, all_checks=True):
Expand Down Expand Up @@ -1108,7 +1112,7 @@ def mutually_broadcastable_shapes(
min_dims: int = 0,
max_dims: Optional[int] = None,
min_side: int = 1,
max_side: Optional[int] = None
max_side: Optional[int] = None,
) -> st.SearchStrategy[BroadcastableShapes]:
"""Return a strategy for generating a specified number of shapes, N, that are
mutually-broadcastable with one another and with the provided "base-shape".
Expand Down Expand Up @@ -1332,7 +1336,7 @@ def basic_indices(
min_dims: int = 0,
max_dims: Optional[int] = None,
allow_newaxis: bool = False,
allow_ellipsis: bool = True
allow_ellipsis: bool = True,
) -> st.SearchStrategy[BasicIndex]:
"""
The ``basic_indices`` strategy generates `basic indexes
Expand Down Expand Up @@ -1396,7 +1400,7 @@ def integer_array_indices(
shape: Shape,
*,
result_shape: SearchStrategy[Shape] = array_shapes(),
dtype: np.dtype = "int"
dtype: np.dtype = "int",
) -> st.SearchStrategy[Tuple[np.ndarray, ...]]:
"""Return a search strategy for tuples of integer-arrays that, when used
to index into an array of shape ``shape``, given an array whose shape
Expand Down
11 changes: 6 additions & 5 deletions hypothesis-python/src/hypothesis/extra/pandas/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def do_draw(self, data):
@st.cacheable
@st.defines_strategy()
def range_indexes(
min_size: int = 0, max_size: Optional[int] = None,
min_size: int = 0,
max_size: Optional[int] = None,
) -> st.SearchStrategy[pandas.RangeIndex]:
"""Provides a strategy which generates an :class:`~pandas.Index` whose
values are 0, 1, ..., n for some n.
Expand Down Expand Up @@ -182,7 +183,7 @@ def indexes(
dtype: Any = None,
min_size: int = 0,
max_size: Optional[int] = None,
unique: bool = True
unique: bool = True,
) -> st.SearchStrategy[pandas.Index]:
"""Provides a strategy for producing a :class:`pandas.Index`.
Expand Down Expand Up @@ -223,7 +224,7 @@ def series(
dtype: Any = None,
index: Optional[st.SearchStrategy[Union[Sequence, pandas.Index]]] = None,
fill: Optional[st.SearchStrategy[Ex]] = None,
unique: bool = False
unique: bool = False,
) -> st.SearchStrategy[pandas.Series]:
"""Provides a strategy for producing a :class:`pandas.Series`.
Expand Down Expand Up @@ -339,7 +340,7 @@ def columns(
dtype: Any = None,
elements: Optional[st.SearchStrategy[Ex]] = None,
fill: Optional[st.SearchStrategy[Ex]] = None,
unique: bool = False
unique: bool = False,
) -> List[column]:
"""A convenience function for producing a list of :class:`column` objects
of the same general shape.
Expand All @@ -366,7 +367,7 @@ def data_frames(
columns: Optional[Sequence[column]] = None,
*,
rows: Optional[st.SearchStrategy[Union[dict, Sequence[Any]]]] = None,
index: Optional[st.SearchStrategy[Ex]] = None
index: Optional[st.SearchStrategy[Ex]] = None,
) -> st.SearchStrategy[pandas.DataFrame]:
"""Provides a strategy for producing a :class:`pandas.DataFrame`.
Expand Down
4 changes: 3 additions & 1 deletion hypothesis-python/src/hypothesis/internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def __balance(self, i):
self.__swap(parent, i)
i = parent
else:
break
# This branch is never taken on versions of Python where dicts
# preserve their insertion order (pypy or cpython >= 3.7)
break # pragma: no cover
while True:
children = [j for j in (2 * i + 1, 2 * i + 2) if j < len(self.data)]
if len(children) == 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ class ConjectureData:
@classmethod
def for_buffer(self, buffer, observer=None):
return ConjectureData(
prefix=buffer, max_length=len(buffer), random=None, observer=observer,
prefix=buffer, max_length=len(buffer), random=None, observer=observer
)

def __init__(self, max_length, prefix, random, observer=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def __repr__(self):
self.__start,
)
else:
return "ConcreteDFA(%r, %r)" % (transitions, self.__accepting,)
return "ConcreteDFA(%r, %r)" % (transitions, self.__accepting)

@property
def start(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def kill_branch(self):
result = None

data = self.new_conjecture_data(
prefix=max((buffer, dummy_data.buffer), key=len), max_length=max_length,
prefix=max((buffer, dummy_data.buffer), key=len), max_length=max_length
)
self.test_function(data)
result = check_result(data.as_result())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ def run_block_program(self, i, description, original, repeats=1):

def shrink_pass_family(f):
def accept(*args):
name = "%s(%s)" % (f.__name__, ", ".join(map(repr, args)),)
name = "%s(%s)" % (f.__name__, ", ".join(map(repr, args)))
if name not in SHRINK_PASS_DEFINITIONS:

def run(self, chooser):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def normalize(
*,
required_successes=100,
allowed_to_update=False,
max_dfas=10
max_dfas=10,
):
"""Attempt to ensure that this test function successfully normalizes - i.e.
whenever it declares a test case to be interesting, we are able
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def sort_regions_with_gaps(self):
"""
for i in range(1, len(self.current) - 1):
if self.current[i - 1] <= self.current[i] <= self.current[i + 1]:
continue
# The `continue` line is optimised out of the bytecode on
# CPython >= 3.7 (https://bugs.python.org/issue2506) and on
# PyPy, and so coverage cannot tell that it has been taken.
continue # pragma: no cover

def can_sort(a, b):
if a < 0 or b > len(self.current):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ def biased_coin(data, p, *, forced=None):
# becomes i > falsey.
result = i > falsey

if i > 1:
if i > 1: # pragma: no branch
# Thanks to bytecode optimisations on CPython >= 3.7 and PyPy
# (see https://bugs.python.org/issue2506), coverage incorrectly
# thinks that this condition is always true. You can trivially
# check by adding `else: assert False` and running the tests.
data.draw_bits(bits, forced=int(result))
break
data.stop_example()
Expand Down
Loading

0 comments on commit c8d9262

Please sign in to comment.