this post was submitted on 29 Aug 2023
24 points (100.0% liked)

Rust

5778 readers
34 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] 0xDEADBEEFCAFE@programming.dev 2 points 1 year ago (1 children)

That's a bummer. I guess what I though was PyO3 type hints was actually just PyCharm guessing at the types.

I tried creating a .pyi file and it seems to be a pretty big improvement over no type hints, but I don't know how to add type hints for modules added with PyModule::add_module and adding the .pyi file seems to make the type checker not know about my other modules.

Would you mind sharing the script for auto generating type hints? Keeping them in sync manually would be pretty annoying.

[โ€“] Walnut356@programming.dev 3 points 1 year ago

Here's the script. It's nothing fancy, and iirc it only works for top level functions/classes. That means you still have to take care of attributes and methods which is a little annoying, but for simple stuff it should save a bit of time.