danepitkin commented on PR #34894:
URL: https://github.com/apache/arrow/pull/34894#issuecomment-1503979067
> Thanks so much for the updates, the optimisation in the types.py looks
great! 👏
>
> > One interesting limitation is if there are docstrings that use curly
braces `{}`. If it's a doctest, we would need to replace `{}` with an
equivalent like `dict()` or `set()`. If it's part of the descriptions, it can
be escaped e.g. `{{}}`
>
> Oh, this is not ideal. What exactly happens in the case where the examples
use curly braces? Does this happen often?
If the example uses curly braces, pyarrow will throw a runtime error:
```
@doc(is_null, datatype="primitive type")
def is_primitive(t):
"""
Example
>>> pydict = {"cat": 0, "dog": 1}
"""
return lib._is_primitive(t.id)
```
```
>>> import pyarrow as pa
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dane/code/arrow/python/pyarrow/__init__.py", line 288, in
<module>
import pyarrow.types as types
File "/Users/dane/code/arrow/python/pyarrow/types.py", line 291, in
<module>
@doc(is_null, datatype="primitive type")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dane/code/arrow/python/pyarrow/util.py", line 76, in decorator
params_applied = [
^
File "/Users/dane/code/arrow/python/pyarrow/util.py", line 77, in
<listcomp>
component.format(**params)
KeyError: '"cat"'
```
The fix would be to replace them like this:
```
>>> pydict = dict("cat": 0, "dog": 1)
```
This mostly shows up in Cython docstrings, which are not applicable at the
moment!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]