sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
238 stars 49 forks source link

Add alised class stubgen #93

Closed sxysxy closed 1 year ago

sxysxy commented 1 year ago

I saw the same issue on https://github.com/sizmailov/pybind11-stubgen/pull/63, but it was not merged?Recently I faced the same problem and I solved it.

I tested it on a private project using pybind11 to bind python extensions and pybind11_stubgen to generate stubs, but I can't show those codes, so I added an simple testing example, for convenience I just use a module written in python instead of a pybind11 module.

class Vector:
  pass

Vector3f = Vector

It will generate stub as follows:

from __future__ import annotations
import test_alias_class
import typing

__all__ = [
    "Vector",
    "Vector3f"
]

class Vector():
    pass
Vector3f = Vector

Test result on current master brunch:

from __future__ import annotations
import test_alias_class
import typing

__all__ = [
    "Vector",
    "Vector3f"
]

class Vector():
    pass
class Vector():
    pass
sizmailov commented 1 year ago

Superceed by #63