Skip to content

stubtest crashes on @override + @overload #18814

Closed
@jorenham

Description

@jorenham

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions