Skip to content

stubgen throws AssertionError for QuantLib #13927

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 · 0 comments
Open

stubgen throws AssertionError for QuantLib #13927

sweemer opened this issue May 3, 2025 · 0 comments

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant