Skip to content

stubtest crashes on @override + @overload #18814

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

Closed
jorenham opened this issue Mar 19, 2025 · 3 comments · Fixed by #18815
Closed

stubtest crashes on @override + @overload #18814

jorenham opened this issue Mar 19, 2025 · 3 comments · Fixed by #18815
Labels
bug mypy got something wrong crash topic-stubtest

Comments

@jorenham
Copy link
Contributor

jorenham commented Mar 19, 2025

When I annotate a method as

    @overload
    @override
    def __new__(cls, /, *, coerce: bool = True) -> Self: ...
    @overload
    def __new__(cls, /, *, na_object: _NaObjectT_co, coerce: bool = True) -> Self: ...

and run stubtest with mypy 1.15.0, I see the following traceback

Traceback (most recent call last):
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 2123, in main
    return test_stubs(parse_options(sys.argv[1:]))
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 1992, in test_stubs
    for error in test_module(module):
                 ~~~~~~~~~~~^^^^^^^^
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 248, in test_module
    yield from verify(stub, runtime, [module_name])
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 426, in verify_mypyfile
    yield from verify(stub_entry, runtime_entry, object_path + [entry])
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 588, in verify_typeinfo
    yield from verify(stub_to_verify, runtime_attr, object_path + [entry])
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 1187, in verify_overloadedfuncdef
    stub_sig = Signature.from_overloadedfuncdef(stub)
  File ".venv/lib/python3.13/site-packages/mypy/stubtest.py", line 845, in from_overloadedfuncdef
    assert func is not None
           ^^^^^^^^^^^^^^^^
AssertionError

The decoration order is irrelevant.

Some context

$ uv run python -c "import sys; print(sys.version)"
3.13.2 (main, Feb  7 2025, 04:13:54) [GCC 11.4.0]
$ uv run mypy --version
mypy 1.15.0 (compiled: yes)
$ uv run stubtest --version
stubtest 1.15.0

Reproducing

@jorenham jorenham added the bug mypy got something wrong label Mar 19, 2025
@hauntsaninja
Copy link
Collaborator

It's too late at night for me to figure out how to get uv to look at my editable install, but I'd bet that #18815 would fix

@jorenham
Copy link
Contributor Author

It's too late at night for me to figure out how to get uv to look at my editable install

You mean uv run --no-editable stubtest ...? That doesn't work for numtype, unless you remove all of the *.py from the numpy site-packages directory (see tool/unstub.py).
But it's easiest to use uv run tool/stubtest.py, which does both automatically in an isolated environment.

I'd bet that #18815 would fix

If you give me a minute, I can verify if it works.

jorenham added a commit to numpy/numtype that referenced this issue Mar 19, 2025
@jorenham
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong crash topic-stubtest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants