-
Notifications
You must be signed in to change notification settings - Fork 3
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
Issue in case of excess Ellipsis ...
at the end of a multi-line doctest statement
#148
Comments
Thanks for the issue @etienneschalk . Could you clarify the issue? What is the difference between the current output and the output you'd want? |
Hello @max-sixty Regarding the current output and output I would want, there is a bug as the last line, here, By trailing Concrete example: on the xarray repo: here is a docstring with a trailing
Let's say I break the docstring...
...and then run pytest-accept on the file: pytest --doctest-modules xarray/core/options.py --accept
We can see that the trailing In the doctest official documentation we can see several examples of trailing It looks similar to the known issues involving the backslashes in docstrings eg #146 |
Ah, thanks a lot for explaining. That does look weird. Generally Would you have a small self-contained example you could paste in? Then we have a shared example that I can attempt to fix. |
The following example should be copy/pastable into a single file. The doctest has a single trailing Ellipsis, and the output is wrong on purpose. Output is File before running pytest-accept: def negate(value: bool) -> bool:
"""This function negates its input
>>> negate(True)
...
True
"""
return not value File after pytest-accept ran on it: def negate(value: bool) -> bool:
"""This function negates its input
>>> negate(True)
False
True
"""
return not value |
Thanks for the excellent example. I spent some time looking into this. Unfortunately, I think it's a problem with python's stdlib. Specifically in this example... def negate(value: bool) -> bool:
"""This function negates its input
>>> negate(True)
...
True
""" ... So in The only way I could see identifying this is to attempt to parse the whole docstring (in this case Let's leave this open for a while. The next step is to put a bug report into python itself. |
Hello, In the context of pydata/xarray#8760 I try to use the ruff formatter to format docstrings. This is an opt-in behaviour introduced in https://astral.sh/blog/ruff-v0.1.8 enabled by adding in pyproject.toml: [tool.ruff.format]
docstring-code-format = true I ran
So it means, fixing this issue might be unneeded if formatters that remove excess Ellipsis were to be generalized in various projects! |
If there is a trailing ellipsis at the end of a doctest statement
My IDE syntax coloring, and various other examples in the xarray codebase suggests me that there should not be any trailing Ellipsis at the end of a multi-line doctest statement, but I thought it was still worth mentioning this edge case!
Screenshot: Diff before and after running pytest-accept
The text was updated successfully, but these errors were encountered: