-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map example from documentation does not type check with 6.43.2 #3296
Comments
|
I don't see how #3293 (which took precedent over #3287), which only changed the annotation of pyright has no issue and infers the correct type Can you point me to a combo of hypothesis/mypy versions where mypy runs clean on |
|
I reproduced this on Hypothesis 6.43.1, so as expected it's not #3287 - that only touched from hypothesis.strategies import lists, integers
s = lists(integers())
reveal_type(s)
reveal_type(sorted)
s2 = s.map(sorted)
reveal_type(s2)Output, reformatted for legibility: So it seems that |
|
|
The `-1 is how |
|
Oh, and @jenshnielsen - thanks very much for reporting this! Even if it turns out not to be a bug in Hypothesis per se, you gave us a fantastic minimal repro which will help us to get it fixed somewhere 😄 |
Huh! 👨🎓 |
|
@Zac-HD @rsokl I think see now how this happens It's indeed a bit more complicated. That pr does indeed only touch given but the specific test where I discovered this https://github.com/QCoDeS/Qcodes/blob/master/qcodes/tests/drivers/test_lakeshore_325.py#L12 uses this combination (or something very similar) inside a given decorator. I bet that before this used to be considered untyped by mypy so that it was not type checked at all but with this change its now considered typed so the fact that mypy flags this construct now becomes clear. |
|
As in mypy will accept with hypothesis 6.43.1 but not with 6.43.2 |
|
Ah, yep, that makes sense. I'll check if |
|
@Zac-HD Personally I would be perfectly happy to add a type ignore comment to my own project and use the latest hypothesis with this bug reported upstream to mypy |
|
@Zac-HD In fact, I think we can use this as an opportunity to overload @overload
def given(
*_given_arguments: Union[SearchStrategy[Any], InferType],
) -> Callable[
[Callable[..., Union[None, Coroutine[Any, Any, None]]]], Callable[..., None]
]:
@overload
def given(
**_given_kwargs: Union[SearchStrategy[Any], InferType],
) -> Callable[
[Callable[..., Union[None, Coroutine[Any, Any, None]]]], Callable[..., None]
]:
def given(
*_given_arguments: Union[SearchStrategy[Any], InferType],
**_given_kwargs: Union[SearchStrategy[Any], InferType],
) -> Callable[
[Callable[..., Union[None, Coroutine[Any, Any, None]]]], Callable[..., None]
]:here, using |
|
Since we've done what we can locally and opened an upstream issue, I'll close this PR. Once again,
|
The following example taken from https://hypothesis.readthedocs.io/en/latest/data.html?highlight=lists#mapping
does no longer type check with 6.43.2 probably due to the changes in #3287
Running mypy 0.942 on (with python 3.9 on windows)
results in
The text was updated successfully, but these errors were encountered: