pytestarch icon indicating copy to clipboard operation
pytestarch copied to clipboard

SyntaxError: invalid escape sequence '\w'

Open ksmolyanin opened this issue 1 year ago • 3 comments

Hello! I'm getting the following error

from pytestarch.diagram_extension.diagram_parser import PumlParser
E     File "/usr/local/lib/python3.11/site-packages/pytestarch/diagram_extension/diagram_parser.py", line 28
E       ANY_ARROW_TEXT = "(-?|\w+-)"  # noqa: W605
E                        ^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\w'

I use

  • Python: 3.11.9
  • pytestarch: 3.0.0

As I understand noqa: W605 disabled warning about that situation but now Python reports it as a syntax error.

Why not use that regex str like this "(-?|\\w+-)" or like this r"(-?|\w+-)"?

ksmolyanin avatar Jul 24 '24 22:07 ksmolyanin

BTW I've changed (locally on my machine) regex strings to use r"..." notation and everything started to work well. So I probably can make a patch for this.

ksmolyanin avatar Jul 25 '24 07:07 ksmolyanin

Hi! Thanks for bringing this to my attention! I don't quite recall why I opted to suppress the warning, but this clearly needs to be fixed. If you want to provide the patch, I would be very happy to merge it. :) Otherwise, I'm going to fix it over the weekend.

zyskarch avatar Jul 25 '24 16:07 zyskarch

I've released the fix as version 3.0.1. Let me know if you're still experiencing issues - if not, I would close the ticket :) Thank you very much for contributing the fix!

zyskarch avatar Jul 27 '24 08:07 zyskarch