Skip to content
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

[BUG]: stubgen generates aliases out-of-order #899

Open
smurfix opened this issue Jan 31, 2025 · 2 comments · May be fixed by #900
Open

[BUG]: stubgen generates aliases out-of-order #899

smurfix opened this issue Jan 31, 2025 · 2 comments · May be fixed by #900

Comments

@smurfix
Copy link
Contributor

smurfix commented Jan 31, 2025

Problem description

This is unlikely to work:

class _ttd_enum_DirDiff(enum.IntFlag):
    __str__ = __repr__
    def __repr__(self, /):
        """Return repr(self)."""
    SAME = 0
    ...

Reproducible example code

enum DirDiff {
        DIRDIFF_SAME    = 0,    ///< Both directions faces to the same direction
};
py::enum_<DirDiff>(m, "DirDiff" ,py::is_flag(),py::is_arithmetic())
        .value("SAME", DirDiff::DIRDIFF_SAME)
        ;
@wjakob
Copy link
Owner

wjakob commented Jan 31, 2025

This is actually a tricky topic. What about types -- do we need to declare them before they can be used, as well? If so, that quickly becomes a very complicated ordering problem that would require a major redesign of the stub generator.

PyRight doesn't care either way, both for aliases and types themselves. MyPy is much stricter. (MyPy is also broken in many ways, so I don't trust it very much these days)

@smurfix
Copy link
Contributor Author

smurfix commented Jan 31, 2025

I agree that this is the "low-hanging fruit" part, but it's the one part that you can't control by simply sorting the stubs, using whatever ad-hoc way happens to work for you. ;-)

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

Successfully merging a pull request may close this issue.

2 participants