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

stubtest raises an exception when a classmethod's first parameter not named cls #16583

Open
Avasam opened this issue Nov 28, 2023 · 0 comments
Open

Comments

@Avasam
Copy link
Contributor

Avasam commented Nov 28, 2023

Crash Report

From python/typeshed#10544 (comment)
Where networkx's source code has:

class EdgeComponentAuxGraph:
    @classmethod
    def construct(EdgeComponentAuxGraph, G): ...

Traceback

Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1891, in <module>
    sys.exit(main())
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1887, in main
    return test_stubs(parse_options(sys.argv[1:]))
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1760, in test_stubs
    for error in test_module(module):
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 223, in test_module
    yield from verify(stub, runtime, [module_name])
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 401, in verify_mypyfile
    yield from verify(stub_entry, runtime_entry, object_path + [entry])
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 543, in verify_typeinfo
    yield from verify(stub_to_verify, runtime_attr, object_path + [entry])
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1261, in verify_decorator
    func = _resolve_funcitem_from_decorator(stub)
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1240, in _resolve_funcitem_from_decorator
    resulting_func = apply_decorator_to_funcitem(decorator, func)
  File "C:\Users\Avasam\AppData\Local\Temp\tmpmhpy63_q\lib\site-packages\mypy\stubtest.py", line 1225, in apply_decorator_to_funcitem
    raise StubtestFailure(
__main__.StubtestFailure: unexpected class argument name 'EdgeComponentAuxGraph' in networkx.algorithms.connectivity.edge_kcomponents.EdgeComponentAuxGraph.construct

To Reproduce

(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)

From my experience, in typeshed, changing any classmethod's first parameter of a class that is present at runtime should raise the exception.

For example, in stubs/urllib3/urllib3/fields.pyi, you could change RequestField.from_tuples's cls parameter to anything else (ie: not_cls). Then run python ./tests/stubtest_third_party.py urllib3.

Your Environment

  • Mypy version used: mypy 1.7.1 (compiled: yes)
  • Mypy command-line flags: (see typeshed)
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.13
  • Operating system and version: Windows 10 Version 10.0.19045 Build 19045
@Avasam Avasam added the crash label Nov 28, 2023
@Avasam Avasam changed the title stubtest crash with a classmethod's first parameter not named cls stubtest raises an exception when a classmethod's first parameter not named cls Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants