-
Notifications
You must be signed in to change notification settings - Fork 779
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
Allow adding docstrings to the classes created with create_exception!
#2016
Comments
Personally I'd prefer not solve this and instead finish refining |
(help with finishing the final bits of design and implementation written there is very much wanted!) |
Yes, that seems reasonable. Is there some workaround one could use at the moment? I would like to be able to call the custom exception as a regular |
The impl_native_exception macro takes a docstring as argument, perhaps we should update the other macros to do this too? See https://github.com/PyO3/pyo3/blob/main/src/exceptions.rs#L210 |
Good suggestion - adding an optional final argument would be backwards-compatible! |
At the moment the recommended way of creating custom exceptions is the
create_exception!
macro. Unfortunately, it does not allow a docstring to be specified (since that docstring will be attached to the macro invocation and not to the actual class it creates), which leads to several problems:#[allow(missing_docs)]
(for the same reason an actual docstring cannot be specified)help()
in REPL, orsphinx.autodoc
)I tried doing an analogue of
class MyError(Exception): pass
in Rust (that's really all I need), but couldn't figure out how to write a constructor.The text was updated successfully, but these errors were encountered: