sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
218 stars 44 forks source link

KeyError: 'pop from an empty set' #202

Closed virtuald closed 7 months ago

virtuald commented 7 months ago

Not sure how this happened, but here's the stack trace in pybind11-stubgen 2.4.1:

pybind11_stubgen - [WARNING] Enum-like str representations were found with no matching mapping to the enum class location.
Use `--enum-class-locations` to specify full path to the following enum(s):
 - EncodingType
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "robotpy_build/command/build_pyi.py", line 167, in <module>
    main()
  File "robotpy_build/command/build_pyi.py", line 163, in main
    pybind11_stubgen.main()
  File "pybind11_stubgen/__init__.py", line 317, in main
    run(
  File "pybind11_stubgen/__init__.py", line 358, in run
    parser.finalize()
  File "pybind11_stubgen/parser/mixins/error_handlers.py", line 61, in finalize
    return super().finalize()
           ^^^^^^^^^^^^^^^^^^
  File "pybind11_stubgen/parser/mixins/fix.py", line 1155, in finalize
    value, import_ = self._repr_to_value_and_import[repr_].pop()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'pop from an empty set'
sizmailov commented 7 months ago

Thanks for the report!

Now I'm looking closer to #196, there are a few problems there. I'll not be able to quickly address it. I'm thinking of reverting #196, unfortunately.

sizmailov commented 7 months ago

Should be solved by #203

ringohoffman commented 7 months ago

@virtuald for my understanding of the origin of this bug... were you using --enum-class-locations when this error occurred? Does it still occur even when you don't use it? (using v2.4.1)

virtuald commented 7 months ago

@ringohoffman I did not specify --enum-class-locations. I have an automated binding tool called robotpy-build which calls stubgen to generate pyi files (see https://github.com/robotpy/robotpy-build/blob/main/robotpy_build/command/build_pyi.py#L152).

I was likely building https://github.com/robotpy/mostrobotpy/ ... but I'm not 100% sure which one of the subprojects I was building. You can do RPYBUILD_PARALLEL=1 ./rdev.sh ci run to build all of the projects, it takes awhile.