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

__init_subclass__ with classmethod raises IndexError in stubtest #15397

Closed
rayzchen opened this issue Jun 8, 2023 · 1 comment · Fixed by #15399
Closed

__init_subclass__ with classmethod raises IndexError in stubtest #15397

rayzchen opened this issue Jun 8, 2023 · 1 comment · Fixed by #15399
Labels
bug mypy got something wrong topic-stubtest

Comments

@rayzchen
Copy link

rayzchen commented Jun 8, 2023

Bug Report

Stubtest raises IndexError: list index out of range when a __init_subclass__ method with the classmethod decorator is used.

To Reproduce

https://github.com/rayzchen/stubtest-bug

Run python -m mypy.stubtest mod

Actual Behavior

init subclass
Traceback (most recent call last):
  File "D:\RayChen\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\RayChen\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 1879, in <module>
    sys.exit(main())
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 1875, in main
    return test_stubs(parse_options(sys.argv[1:]))
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 1748, in test_stubs
    for error in test_module(module):
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 218, in test_module
    yield from verify(stub, runtime, [module_name])
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 396, in verify_mypyfile
    yield from verify(stub_entry, runtime_entry, object_path + [entry])
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 534, in verify_typeinfo
    yield from verify(stub_to_verify, runtime_attr, object_path + [entry])
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 1254, in verify_decorator
    yield from verify(func, runtime, object_path)
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 974, in verify_funcitem
    stub_sig = Signature.from_funcitem(stub)
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 730, in from_funcitem
    stub_args = maybe_strip_cls(stub.name, stub.arguments)
  File "D:\RayChen\Programs\Python\Python310\lib\site-packages\mypy\stubtest.py", line 674, in maybe_strip_cls
    if args[0].variable.name == "cls":
IndexError: list index out of range

Your Environment

  • Mypy version used: 1.3.0
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10.6
@rayzchen rayzchen added the bug mypy got something wrong label Jun 8, 2023
@hauntsaninja
Copy link
Collaborator

Thanks for the report!

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

Successfully merging a pull request may close this issue.

3 participants