PyCQA / flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://flake8.pycqa.org
Other
3.39k stars 306 forks source link

Ignore "SyntaxWarning: invalid escape sequence" #1913

Closed AFLSC closed 7 months ago

AFLSC commented 7 months ago

describe the request

After updating flake8, I get many ":line: SyntaxWarning: invalid escape sequence '\x'" These appear because in some comments we specify network paths like \network\xyz. Here flake8 assumes I wanted to escape a character. It would be nice to be able to ignore those outputs as they clog up the command line when running it locally

sigmavirus24 commented 7 months ago

This is not a bug in flake8. Your strings are invalid in Python 3 which is why us trying to parse it with the standard library fails. Please look up rae strings and in the future fill out the entire issue template

AFLSC commented 7 months ago

Thanks for the quick reply, but I have 2 follow up questions: The comments I mentioned can look like this for example: "To find the files uploaded, look at \\network\xyz". Using raw strings would look like this "To find the files uploaded, look at r'\\network\xyz'" or this r"To find the files uploaded, look at \\network\xyz, both of which I don't think are nice since it's all in a comment anyways and not a variable. Especially in docstrings I don't want to add "r" every time now Also which parts of the issue template? I only found a reference to the documentation that I shouldn't just write "I want this changed", and the rest of the template only has 2 notes and the prompt to describe what I want. Maybe I overlooked something, since I don't create issues here so often

sigmavirus24 commented 7 months ago

Also which parts of the issue template? I only found a reference to the documentation that I shouldn't just write "I want this changed", and the rest of the template only has 2 notes and the prompt to describe what I want. Maybe I overlooked something, since I don't create issues here so often

https://github.com/PyCQA/flake8/blob/main/.github/ISSUE_TEMPLATE/01_bug.yml

You're effectively trying to report a bug, but there is no information about which version of Flake8, python, etc. you're using and no minimal reproducible example.

AFLSC commented 7 months ago

Ah I guess that's where the problem was. I thought it was more of a feature request, so I didn't look at the bug report template, sorry. I am using python 3.12.1 with flake8 version 7.0.0 My command used was flake8 . --ignore=E401,E302,F821,E265,E306,E305,E402,E124,E121,E501,E722,W605,W504,W503, but the reports also appear with "flake8 ." Do you think this ticket can be reopened this way? (or if I do an actual bug report)

AFLSC commented 7 months ago

Okay I just noticed it's not only with flake8, but a general python issue

asottile commented 7 months ago

in short the linter is correct and you would do best to not ignore it