Skip to content

Issue with docstrings containing backslashes at the end of line #146

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

Closed
etienneschalk opened this issue Feb 5, 2024 · 1 comment
Closed

Comments

@etienneschalk
Copy link

etienneschalk commented Feb 5, 2024

Hi,

I am currently using pytest-accept for this issue of xarray: pydata/xarray#8690

I noticed a bug when a docstring contains a backslash at the end of line, then the lines are not properly replaced, an offset is introduced and it breaks the docstring

Example of a docstring that will surely fail on the xarray repo

Zoom on the section containing a backslash:

   combine_attrs : {"drop", "identical", "no_conflicts", "drop_conflicts", \
                     "override"} or callable, default: "override"

This docstring will make the auto-replacement fail. I attach here a screenshot to visually see the issue:

Screenshot from 2024-02-05 23-20-24

When removing the backslash, the pytest-accept tool successfully replace. Currently as a way to mitigate, I plan to remove all the backslashes at ends of line, running pytest-accept and then git revert the backslash removal.

Thanks!

Edit: the issue is already known and mentioned in the README

it reports line numbers incorrectly in some cases — two docstring lines separated with continuation character \ is counted as one, meaning this library will not have access to the correct line number for doctest inputs and outputs.

@max-sixty
Copy link
Owner

Yes, this is covered in the Readme...

If there are better approach, I'm very open to those...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants