Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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
jklymak opened this issue May 29, 2018 · 11 comments
Closed

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

jklymak opened this issue May 29, 2018 · 11 comments

Comments

@jklymak
Copy link
Member

jklymak commented May 29, 2018

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?

@jklymak jklymak added Documentation topic: testing status: needs clarification Issues that need more information to resolve. labels May 29, 2018
@jklymak
Copy link
Member Author

jklymak commented May 29, 2018

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....

@timhoffm
Copy link
Member

Please try if this fixes your issue.

@ImportanceOfBeingErnest
Copy link
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.

@jklymak
Copy link
Member Author

jklymak commented May 29, 2018

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...

@jklymak
Copy link
Member Author

jklymak commented May 29, 2018

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...

@jklymak jklymak reopened this May 29, 2018
@timhoffm
Copy link
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.

@QuLogic
Copy link
Member

QuLogic commented May 29, 2018

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

@tacaswell
Copy link
Member

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

@tacaswell tacaswell added this to the v2.2.3 milestone May 30, 2018
@jklymak jklymak added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. and removed status: needs clarification Issues that need more information to resolve. labels Jun 21, 2018
@jklymak
Copy link
Member Author

jklymak commented Jul 5, 2018

This got fixed....

@jklymak jklymak closed this as completed Jul 5, 2018
@QuLogic
Copy link
Member

QuLogic commented Jul 8, 2018

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.

@QuLogic QuLogic reopened this Jul 8, 2018
@jklymak jklymak modified the milestones: v2.2.3, v3.1 Jul 16, 2018
@jklymak jklymak removed the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 13, 2018
@jklymak jklymak modified the milestones: v3.1.0, v3.2.0 Feb 27, 2019
@timhoffm
Copy link
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
Projects
None yet
Development

No branches or pull requests

5 participants