Skip to content

TST: testing not catching bad escape sequences in doc strings #11335

Closed

Description

@jklymak

Bug report

Doc strings like

        """
        Initialize the artist inspector with an `Artist` or an iterable of
        `Artist`\s.  If an iterable is used, we assume it is a homogeneous
        sequence (all `Artists` are of the same type) and it is your
        responsibility to make sure this is so.
        """

Cause SyntaxError: invalid escape sequence \s on my machine. Somehow they aren't crashing the test suite?

Activity

  1. jklymak commented on May 29, 2018

    @jklymak
    MemberAuthor

    I only have this problem on my at-home machine. So maybe a setup issue. At work, which I thought was basically the same install, things work fine....

  2. timhoffm commented on May 29, 2018

    @timhoffm
    Member

    Please try if this fixes your issue.

  3. ImportanceOfBeingErnest commented on May 29, 2018

    @ImportanceOfBeingErnest
    Member

    According to escaping-mechanism and character-level-inline-markup the backslash is a valid way to escape any character.

    It is possible to mark up individual characters within a word with backslash escapes (see Escaping Mechanism above). Backslash escapes can be used to allow arbitrary text to immediately follow inline markup:
    Python ``list``\s use square bracket syntax.
    The backslash will disappear from the processed document. The word "list" will appear as inline literal text, and the letter "s" will immediately follow it as normal text, with no space in-between.

  4. jklymak commented on May 29, 2018

    @jklymak
    MemberAuthor

    Yes, #11336 fixes the problem on my at-home machine (I didn't test your PR, but thats what I did to get the tests to run).

    OTOH, it doesn't a) explain why the two machines are different despite having the same operating system and python/matplotlib installed the same way, or b) how we can make sure future docstrings that have backslashes get an r in front of them...

  5. jklymak commented on May 29, 2018

    @jklymak
    MemberAuthor

    Re-opening as #11336 fixed the cause not the symptom 😉. I think we want to have a test that makes sure PEP-0257 is followed wrt escaped docstrings. Again, not sure what the difference is between my machines, but I can't imagine I'll be the only person burned by this in the future...

  6. timhoffm commented on May 29, 2018

    @timhoffm
    Member

    Python 3.6 introduced this as a silent warning https://bugs.python.org/issue27364. Maybe you have different configurations for warnings? That would also be the path to note missing raw strings in our code base.

  7. QuLogic commented on May 29, 2018

    @QuLogic
    Member

    tests.py turns those warnings into errors, but we stopped using that on Travis a long time ago.

  8. tacaswell commented on May 30, 2018

    @tacaswell
    Member

    We should re-enable those warnings on travis (for both 2.2.x and master).

  9. added this to the v2.2.3 milestone on May 30, 2018
  10. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    and removed on Jun 21, 2018
  11. jklymak commented on Jul 5, 2018

    @jklymak
    MemberAuthor

    This got fixed....

  12. QuLogic commented on Jul 8, 2018

    @QuLogic
    Member

    Did it? We still don't use tests.py, so things are not checked. I fixed several new ones in #11477. We can install the flake8-invalid-escape-sequences plugin, or wait until the next minor release of flake8 which will use pycodestyle 2.4.0, that supports this builtin.

  13. reopened this on Jul 8, 2018
  14. modified the milestones: v2.2.3, v3.1 on Jul 16, 2018
  15. removed
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Aug 13, 2018
  16. modified the milestones: v3.1.0, v3.2.0 on Feb 27, 2019
  17. timhoffm commented on Aug 26, 2019

    @timhoffm
    Member

    Travis CI flake8 uses pycodestyle 2.5.0. So W605 "invalid escape sequence ‘x'" should be checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions