Skip to content

DOC: backslash removed for read_clipboard #51868

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
1 task done
wjandrea opened this issue Mar 9, 2023 · 3 comments · Fixed by #52285
Closed
1 task done

DOC: backslash removed for read_clipboard #51868

wjandrea opened this issue Mar 9, 2023 · 3 comments · Fixed by #52285
Labels

Comments

@wjandrea
Copy link
Contributor

wjandrea commented Mar 9, 2023

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.read_clipboard.html

Documentation problem

Backslash is missing in the Parameters section:

pandas.read_clipboard(sep='\\s+', **kwargs)
...
Parameters
sep : str, default ‘s+’
A string or regex delimiter. The default of ‘s+’ denotes one or more whitespace characters.


Relevant source code:

def read_clipboard(sep: str = r"\s+", **kwargs):  # pragma: no cover
    r"""
    ...

    Parameters
    ----------
    sep : str, default '\s+'
        A string or regex delimiter. The default of '\s+' denotes
        one or more whitespace characters.

    ...
    """

Suggested fix for documentation

I believe your documentation generator is removing the backslash at some point, so hopefully there's a way to turn that off.

I don't believe this issue has much impact. At worst it could confuse some newcomers, that's about it.

@wjandrea wjandrea added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 9, 2023
@topper-123
Copy link
Contributor

Hmm, if we escape the backslash, the raw doc string is wrong (people use that too, e.g. in editors). So this may not be fixable, though the problem is clear enough.

Suggestions welcome on how to fix this of course, but we may have to close it as a cantfix...

@topper-123 topper-123 removed the Needs Triage Issue that has not been reviewed by a pandas team member label Mar 27, 2023
@wjandrea
Copy link
Contributor Author

wjandrea commented Mar 29, 2023

@topper-123 Now that I think about it, the default is actually '\\s+' (from r'\s+') and '\s' is deprecated syntax. So escaping it would be fine, no? The docs would end up with '\s+', which is not ideal, but at least better.

To be extra clear:

  • the signature is: r'\s+' -> '\\s+'
  • the docstring says: r"""... '\s+' ...""" -> "... '\\s+' ..." -> but then printed as: ... '\s+' ..., which shows the deprecated syntax
  • if you escaped the docstring: r"""... '\\s+' ...""" -> "... '\\\\s+' ..." -> printed as: ... '\\s+' ...

@topper-123
Copy link
Contributor

yes, I think you are right. PR on this welcome.

wjandrea added a commit to wjandrea/pandas that referenced this issue Mar 29, 2023
mroeschke pushed a commit that referenced this issue Mar 29, 2023
Escape backslash in read_clipboard docstring

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

Successfully merging a pull request may close this issue.

2 participants