Skip to content
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

No error after outer quotes are changed per Q003 if inner quotes are still escaped #98

Open
rpdelaney opened this issue May 11, 2020 · 3 comments

Comments

@rpdelaney
Copy link

Possibly related #69 , #77

  1. 'str\'i\'ng' Q003
  2. "str\'i\'ng" No errors

The first line gives Q003 while the second line emits no errors. I took the ultimate aim of Q003 to be to eliminate escaped quotes wherever possible: if I am correct, then I suggest we should emit an additional error to actually do the un-escaping.

I don't have a considered opinion about what that should look like, but if the pump needs priming it could be something like Q004 "Remove unnecessarily escaped quotes."

@twolfson
Copy link
Collaborator

Seems like a reasonable request 👍

I think that Q004 "Remove unnecessarily escaped quotes" sounds good to me =) (no period needed)

@rpdelaney
Copy link
Author

There's a plugin flake8-strings that says on the tin that is does this, but I haven't tried it. MIT license. Maybe we could crib from there.

@JoeHitchen
Copy link
Collaborator

This seems reasonable to me, but I think a little nuiance is needed to handle cases of literal backslashes:

  • 'str\'i\'ng - Q003
  • "str\'i\'ng" - Q004
  • "str\\'i\\'ng" - Acceptable, since \\' is intended to produce the literal \' rather than to escape '
  • r"str\'i\'ng" - Acceptable, since \' is interpreted literally by raw strings

There are probably more cases to consider along these lines too!

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

3 participants