best practices for setting #[pyclass(module = ...)] #1365
-
This thread is about some issues that Can anyone recommend best practices for this sort of thing? Should I set my |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Is there any code snippet/repository to reproduce the |
Beta Was this translation helpful? Give feedback.
-
I have no idea how $ griffe dump blake3 -LDEBUG
INFO Loading package blake3
DEBUG Found blake3: loading
DEBUG Loading path /Users/messense/.pyenv/versions/3.11.0/envs/test-3.11/lib/python3.11/site-packages/blake3/__init__.py
DEBUG Cannot parse __all__ assignment: blake3.__all__ (<class 'ast.Attribute'>)
DEBUG Loading path /Users/messense/.pyenv/versions/3.11.0/envs/test-3.11/lib/python3.11/site-packages/blake3/blake3.cpython-311-darwin.so
INFO Finished loading packages
{
"blake3": {
"kind": "module",
"name": "blake3",
"labels": [],
"members": [
{
"kind": "alias",
"name": "blake3/blake3/*",
"target_path": "blake3.blake3",
"lineno": 1,
"endlineno": 1
},
{
"kind": "attribute",
"name": "__doc__",
"lineno": 3,
"endlineno": 3,
"labels": [
"module-attribute"
],
"members": [],
"value": "blake3.__doc__"
},
{
"kind": "attribute",
"name": "__all__",
"lineno": 5,
"endlineno": 5,
"labels": [
"module-attribute"
],
"members": [],
"value": "blake3.__all__"
},
{
"kind": "module",
"name": "blake3",
"docstring": {
"value": "Python bindings for the official Rust implementation of BLAKE3\n(https://github.com/BLAKE3-team/BLAKE3). This module provides a single\nclass, also called `blake3.` The interface is similar to `hashlib` from\nthe standard library, which provides `blake2b`, `md5`, etc.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [
{
"kind": "attribute",
"name": "__all__",
"docstring": {
"value": "Built-in mutable sequence.\n\nIf no argument is given, the constructor creates a new empty list.\nThe argument must be an iterable if specified.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "['blake3', '__version__']"
},
{
"kind": "attribute",
"name": "__doc__",
"docstring": {
"value": "str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "'Python bindings for the official Rust implementation of BLAKE3\\n(https://github.com/BLAKE3-team/BLAKE3). This module provides a single\\nclass, also called `blake3.` The interface is similar to `hashlib` from\\nthe standard library, which provides `blake2b`, `md5`, etc.'"
},
{
"kind": "attribute",
"name": "__file__",
"docstring": {
"value": "str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "'/Users/messense/.pyenv/versions/3.11.0/envs/test-3.11/lib/python3.11/site-packages/blake3/blake3.cpython-311-darwin.so'"
},
{
"kind": "attribute",
"name": "__name__",
"docstring": {
"value": "str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "'blake3.blake3'"
},
{
"kind": "attribute",
"name": "__package__",
"docstring": {
"value": "str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "'blake3'"
},
{
"kind": "attribute",
"name": "__version__",
"docstring": {
"value": "str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
"lineno": null,
"endlineno": null
},
"labels": [],
"members": [],
"value": "'0.3.2'"
},
{
"kind": "alias",
"name": "blake3",
"target_path": "blake3.blake3"
}
],
"filepath": "/Users/messense/.pyenv/versions/3.11.0/envs/test-3.11/lib/python3.11/site-packages/blake3/blake3.cpython-311-darwin.so"
}
],
"filepath": "/Users/messense/.pyenv/versions/3.11.0/envs/test-3.11/lib/python3.11/site-packages/blake3/__init__.py"
}
} There's not much we can do here in maturin except providing a escape hatch for the automatically added module wrapper (
Maybe, but if you want it to be explicit, perhaps switch to mixed Rust/Python project layout is better. |
Beta Was this translation helpful? Give feedback.
I have no idea how
griffe
works internally, but from thegriffe dump blake3
output I guess thatgriffe
only parses from files without actually importing them.