Skip to content

stubgen throws AssertionError for QuantLib #19031

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

Open
sweemer opened this issue May 3, 2025 · 3 comments
Open

stubgen throws AssertionError for QuantLib #19031

sweemer opened this issue May 3, 2025 · 3 comments
Labels
bug mypy got something wrong topic-stubgen

Comments

@sweemer
Copy link

sweemer commented May 3, 2025

Hello, I am getting the error below when trying to create baseline stubs for the QuantLib package.

QuantLib's python bindings are generated using SWIG. Is this supported? I tried googling for any known limitations with SWIG but couldn't find any.

I'm very new to typeshed so apologies if I'm doing something silly.

$ python3 ./scripts/create_baseline_stubs.py QuantLib
Using detected package "QuantLib" for project "QuantLib"
Suggestion: Try again with --package argument if that's not what you wanted
Running stubgen: stubgen -o stubs/QuantLib -p QuantLib
Traceback (most recent call last):
  File "/usr/local/py-utils/bin/stubgen", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "mypy/stubgen.py", line 1989, in main
  File "mypy/stubgen.py", line 1813, in generate_stubs
  File "/usr/local/py-utils/venvs/mypy/lib/python3.12/site-packages/mypy/stubgenc.py", line 179, in generate_stub_for_c_module
    gen.generate_module()
  File "/usr/local/py-utils/venvs/mypy/lib/python3.12/site-packages/mypy/stubgenc.py", line 451, in generate_module
    self.generate_variable_stub(name, obj, output=variables)
  File "/usr/local/py-utils/venvs/mypy/lib/python3.12/site-packages/mypy/stubgenc.py", line 901, in generate_variable_stub
    type_str = self.strip_or_import(self.get_type_annotation(obj))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py-utils/venvs/mypy/lib/python3.12/site-packages/mypy/stubgenc.py", line 535, in get_type_annotation
    return self.get_type_fullname(type(obj))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/py-utils/venvs/mypy/lib/python3.12/site-packages/mypy/stubgenc.py", line 768, in get_type_fullname
    assert module_name is not None, typ
AssertionError: <class 'swigvarlink'>
Traceback (most recent call last):
  File "/workspaces/typeshed/./scripts/create_baseline_stubs.py", line 253, in <module>
    main()
  File "/workspaces/typeshed/./scripts/create_baseline_stubs.py", line 234, in main
    run_stubgen(package, stub_dir)
  File "/workspaces/typeshed/./scripts/create_baseline_stubs.py", line 57, in run_stubgen
    subprocess.run(["stubgen", "-o", output, "-p", package, "--export-less"], check=True)
  File "/home/codespace/.python/current/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['stubgen', '-o', 'stubs/QuantLib', '-p', 'QuantLib', '--export-less']' returned non-zero exit status 1.
@srittau
Copy link
Contributor

srittau commented May 5, 2025

This sounds like a bug in stubgen to me. Which version of stubgen/mypy are you using?

Also Cc @JelleZijlstra @AlexWaygood Could one of you move this to the mypy issue tracker?

@AlexWaygood
Copy link
Member

Also Cc @JelleZijlstra @AlexWaygood Could one of you move this to the mypy issue tracker?

I can't because I'm only a mypy triager, not a maintainer. @sobolevn, @JelleZijlstra or @hauntsaninja can!

@sobolevn sobolevn transferred this issue from python/typeshed May 5, 2025
@sobolevn
Copy link
Member

sobolevn commented May 5, 2025

done :)

@sobolevn sobolevn added bug mypy got something wrong topic-stubgen labels May 5, 2025
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-stubgen
Projects
None yet
Development

No branches or pull requests

4 participants