#9 Fix invalid escape sequence SyntaxWarning from regex pattern
Closed by music. Opened by music.
music/spectool invalid-escape  into  master

Download 9.patch

Fixes:

$ python3.12 ./spectool --help
/home/ben/src/forks/spectool/./spectool:101: SyntaxWarning: invalid escape sequence '\s'
  tag_re = re.compile("^(?P<tag>" + "|".join(interesting_tags) + "):\s*(?P<val>.*)\s*$", re.IGNORECASE)
[]
$ pycodestyle ./spectool | grep escape
./spectool:101:71: W605 invalid escape sequence '\s'
./spectool:101:85: W605 invalid escape sequence '\s'

The offending string literal is converted to a raw string literal so that backslash-escapes are not interpreted. (The alternative would be to backslash-escape the backslashes, "):\\s*(?P<val>.*)\\s*$", but using a raw string is easier to read and is a standard approach to this issue.)

This was based on a discussion on Matrix, but it turns out that the current upstream for spectool is https://pagure.io/rpmdevtools/blob/main/f/rpmdev-spectool, and the original reporter was using this outdated repository instead. Closing this PR since the issue doesn’t exist in rpmdevtools, and the original reporter should just use the RPM-packaged version from rpmdevtools instead.

Pull-Request has been closed by music

Metadata