Skip to content

Commit

Permalink
Compat for latest libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Apr 16, 2023
1 parent 009b950 commit 8ebc266
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch silences a false alarm from :pypi:`mypy==1.2.0 <mypy>`.
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/internal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_args(
# remove at Python 3.7 end-of-life
from collections.abc import Callable as _Callable

def get_origin(tp: Any) -> typing.Optional[Any]: # pragma: no cover
def get_origin(tp: Any) -> typing.Optional[Any]: # pragma: no cover # type: ignore
"""Get the unsubscripted version of a type.
This supports generic types, Callable, Tuple, Union, Literal, Final and ClassVar.
Return None for unsupported types. Examples::
Expand Down
43 changes: 26 additions & 17 deletions hypothesis-python/tests/pandas/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# 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/.

import warnings

import numpy as np
import pandas
import pytest
Expand Down Expand Up @@ -82,7 +84,7 @@ def test_generate_arbitrary_indices(data):
st.one_of(
npst.boolean_dtypes(),
npst.integer_dtypes(endianness="="),
npst.floating_dtypes(endianness="="),
npst.floating_dtypes(endianness="=", sizes=(32, 64)),
npst.complex_number_dtypes(endianness="="),
npst.datetime64_dtypes(endianness="="),
npst.timedelta64_dtypes(endianness="="),
Expand All @@ -94,23 +96,30 @@ def test_generate_arbitrary_indices(data):
converted_dtype = pandas.Index([], dtype=dtype).dtype

try:
inferred_dtype = pandas.Index([data.draw(npst.from_dtype(dtype))]).dtype

if pass_elements:
elements = npst.from_dtype(dtype)
dtype = None
else:
elements = None

index = data.draw(
pdst.indexes(
elements=elements,
dtype=dtype,
min_size=min_size,
max_size=max_size,
unique=unique,
elem = data.draw(npst.from_dtype(dtype))

with warnings.catch_warnings():
warnings.simplefilter("error")
if np.dtype.kind == "c":
warnings.simplefilter("ignore", np.ComplexWarning)

inferred_dtype = pandas.Index([elem]).dtype

if pass_elements:
elements = npst.from_dtype(dtype)
dtype = None
else:
elements = None

index = data.draw(
pdst.indexes(
elements=elements,
dtype=dtype,
min_size=min_size,
max_size=max_size,
unique=unique,
)
)
)

except Exception as e:
if type(e).__name__ == "OutOfBoundsDatetime":
Expand Down

0 comments on commit 8ebc266

Please sign in to comment.