Opened 3 years ago

Closed 3 years ago

#28550 closed defect (fixed)

DeprecationWarning: invalid escape sequence in docstrings when building with py3

Reported by: Steven Trogdon Owned by:
Priority: major Milestone: sage-9.0
Component: documentation Keywords: python3
Cc: Merged in:
Authors: Steven Trogdon Reviewers: John Palmieri
Report Upstream: N/A Work issues:
Branch: 045be4c (Commits, GitHub, GitLab) Commit: 045be4cc062c595fc3eb8ee9cce54efbc6c91325
Dependencies: Stopgaps:

Status badges

Description

This is a follow-up to #28408, #27521 and #26984. Building the html docs for sage-8.9 with python3 I have the following DeprecationWarnings:

[repl     ] <unknown>:181: DeprecationWarning: invalid escape sequence \)
[repl     ] <unknown>:365: DeprecationWarning: invalid escape sequence \w
[combinat ] <unknown>:265: DeprecationWarning: invalid escape sequence \l
[combinat ] <unknown>:1274: DeprecationWarning: invalid escape sequence \G

Change History (8)

comment:1 Changed 3 years ago by Steven Trogdon

I believe the warnings in combinat can be resolved with

  • src/sage/combinat/posets/hasse_diagram.py

    diff --git a/src/sage/combinat/posets/hasse_diagram.py b/src/sage/combinat/posets/hasse_diagram.py
    index 02b03e6dbc..69d48fbf43 100644
    a b class HasseDiagram(DiGraph): 
    12311231        return M
    12321232
    12331233    def lequal_matrix(self, boolean=False):
    1234         """
     1234        r"""
    12351235        Return a matrix whose ``(i,j)`` entry is 1 if ``i`` is less
    12361236        than ``j`` in the poset, and 0 otherwise; and redefines
    12371237        ``__lt__`` to use the boolean version of this matrix.
  • src/sage/combinat/shifted_primed_tableau.py

    diff --git a/src/sage/combinat/shifted_primed_tableau.py b/src/sage/combinat/shifted_primed_tableau.py
    index 7fac2e48b1..ca76bed033 100644
    a b class ShiftedPrimedTableau(ClonableArray): 
    242242            raise ValueError("{} is not an element of Shifted Primed Tableaux".format(self))
    243243
    244244    def is_standard(self):
    245         """
     245        r"""
    246246        Return ``True`` if the entries of ``self`` are in bijection with
    247247        positive primed integers `1', 1, 2', \ldots, n`.

but I haven't been able to find the source of the warnings in repl.

comment:2 Changed 3 years ago by John Palmieri

Got it! The problem comes from IPython.core.inputtransformer, which is imported in sage.repl.interpreter. Lines 180-181:

def assemble_logical_lines():
    """Join lines following explicit line continuations (\)"""

Adding r to the start of the triple quotes fixes the problem with \).

Line 365:

    cellmagic_help_re = re.compile('%%\w+\?')

This is in Python code, so I don't know why it causes any problems, but prefixing this quote with r fixes the problem with \w.

The bad news is that this file is part of IPython and so is not under our control. The good news is that we should update to a new version of IPython soon (#28197), and presumably these are fixed there. This update may be Python 3 only, but see #28190. In any case, I suggest ignoring these two issues and fixing the two in combinat.

comment:3 Changed 3 years ago by Steven Trogdon

Branch: u/strogdon/combinat_dep_warns

comment:4 Changed 3 years ago by Steven Trogdon

Authors: Steven Trogdon
Commit: 045be4cc062c595fc3eb8ee9cce54efbc6c91325
Status: newneeds_review

OK, so the changes have been pushed.


New commits:

045be4cfix escape sequence deprecationwarnings in docstrings

comment:5 Changed 3 years ago by John Palmieri

Reviewers: John Palmieri
Status: needs_reviewpositive_review

Looks good, thanks.

comment:6 in reply to:  2 ; Changed 3 years ago by Steven Trogdon

Replying to jhpalmieri:

Got it! The problem comes from IPython.core.inputtransformer, which is imported in sage.repl.interpreter. Lines 180-181:

def assemble_logical_lines():
    """Join lines following explicit line continuations (\)"""

Adding r to the start of the triple quotes fixes the problem with \).

Line 365:

    cellmagic_help_re = re.compile('%%\w+\?')

This is in Python code, so I don't know why it causes any problems, but prefixing this quote with r fixes the problem with \w.

The bad news is that this file is part of IPython and so is not under our control. The good news is that we should update to a new version of IPython soon (#28197), and presumably these are fixed there. This update may be Python 3 only, but see #28190. In any case, I suggest ignoring these two issues and fixing the two in combinat.

The ipython-7.5.0 that's available on Gentoo has these corrections.

comment:7 in reply to:  6 Changed 3 years ago by John Palmieri

Replying to strogdon:

The ipython-7.5.0 that's available on Gentoo has these corrections.

That's good to know. Thank you for checking.

comment:8 Changed 3 years ago by Volker Braun

Branch: u/strogdon/combinat_dep_warns045be4cc062c595fc3eb8ee9cce54efbc6c91325
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.