Skip to content

stubtest crashes on class decorator in overloaded function #19689

@brianschubert

Description

@brianschubert

Crash Report

This crashes stubtest on master:

from typing import overload

class _decorator:
    def __init__(self, func: object) -> None: ...
    def __call__(self, x: str) -> str: ...

@overload
def foo(x: int) -> int: ...
@overload
@_decorator
def foo(x: str) -> str: ...

Traceback

Traceback (most recent call last):
  File "/home/brian/Projects/open-contrib/mypy/.venv313/bin/stubtest", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 2188, in main
    return test_stubs(parse_options(sys.argv[1:]))
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 2042, in test_stubs
    for error in test_module(module):
                 ~~~~~~~~~~~^^^^^^^^
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 248, in test_module
    yield from verify(stub, runtime, [module_name])
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 427, in verify_mypyfile
    yield from verify(stub_entry, runtime_entry, object_path + [entry])
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 1206, in verify_overloadedfuncdef
    stub_sig = Signature.from_overloadedfuncdef(stub)
  File "/home/brian/Projects/open-contrib/mypy/mypy/stubtest.py", line 861, in from_overloadedfuncdef
    assert func is not None, "Failed to resolve decorated overload"
           ^^^^^^^^^^^^^^^^
AssertionError: Failed to resolve decorated overload

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions