Skip to content
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

ParamSpec for @st.composite annotations #3219

Closed
wants to merge 2 commits into from

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Jan 17, 2022

MVP version of #3212; st.functions() is going to be harder thanks to longstanding mypy issues.

@Zac-HD
Copy link
Member Author

Zac-HD commented Jan 17, 2022

Sadly, it looks like mypy support just isn't there yet:

=================================== FAILURES ===================================
________________________ test_mypy_passes_on_hypothesis ________________________
Traceback (most recent call last):
  File "/home/runner/work/hypothesis/hypothesis/whole-repo-tests/test_type_hints.py", line 20, in test_mypy_passes_on_hypothesis
    pip_tool("mypy", PYTHON_SRC)
  File "/home/runner/work/hypothesis/hypothesis/tooling/src/hypothesistooling/scripts.py", line 69, in pip_tool
    sys.exit(r)
SystemExit: 1
----------------------------- Captured stdout call -----------------------------
mypy /home/runner/work/hypothesis/hypothesis/hypothesis-python/src
hypothesis-python/src/hypothesis/strategies/_internal/core.py:1501: error: The first argument to Callable must be a list of types or "..."
hypothesis-python/src/hypothesis/strategies/_internal/core.py:1502: error: The first argument to Callable must be a list of types or "..."
Found 2 errors in 1 file (checked 100 source files)
_________________________ test_composite_type_tracing __________________________
Traceback (most recent call last):
  File "/home/runner/work/hypothesis/hypothesis/whole-repo-tests/test_type_hints.py", line 155, in test_composite_type_tracing
    assert got == "def (x: int) -> int"
AssertionError: assert 'Any' == 'def (x: int) -> int'
  - def (x: int) -> int
  + Any

Let's revisit in a few months, or when the changelog suggests this might have changed.

@rsokl
Copy link
Contributor

rsokl commented Jan 17, 2022

😭

@gjoseph92
Copy link

Yeah, seems like MyPy doesn't support Concatenate yet: python/mypy#11833, http://mypy-lang.blogspot.com/2021/12/mypy-0930-released.html#:~:text=Note%20that%20typing.Concatenate%20and%20some%20other%20use%20cases%20are%20still%20not%20supported.

However, other typecheckers (pyright, i.e. VSCode) do, and this annotation would improve the autocomplete experience a lot for Hypothesis users using language servers that do support it. I'm curious what policy (if any) you have on these new typing features; it is part of the spec and supported by typing-extensions, even if one particular type checker doesn't handle it yet.

@Zac-HD
Copy link
Member Author

Zac-HD commented Jan 18, 2022

Generally we're happy to adopt as soon as that's possible without breaking things; which in this case requires basic support in mypy - it doesn't need to be checked, but erroring out is unacceptable 😕

Hopefully we can revisit this soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants