Skip to content

stubgen throws AssertionError for QuantLib #19031

Closed
@sweemer

Description

@sweemer

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions