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

Skip to content

Fix SyntaxWarning: invalid escape sequence '\e'#911

Open
Avasam wants to merge 1 commit intoasweigart:masterfrom
Avasam:patch-1
Open

Fix SyntaxWarning: invalid escape sequence '\e'#911
Avasam wants to merge 1 commit intoasweigart:masterfrom
Avasam:patch-1

Conversation

@Avasam
Copy link
Copy Markdown

@Avasam Avasam commented Feb 3, 2025

Closes #423

'\t': _display.keysym_to_keycode(Xlib.XK.string_to_keysym('Tab')),
'\n': _display.keysym_to_keycode(Xlib.XK.string_to_keysym('Return')), # for some reason this needs to be cr, not lf
'\r': _display.keysym_to_keycode(Xlib.XK.string_to_keysym('Return')),
'\e': _display.keysym_to_keycode(Xlib.XK.string_to_keysym('Escape')),
Copy link
Copy Markdown

@cclauss cclauss Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a raw string.

    r'\e': _display.keysym_to_keycode(Xlib.XK.string_to_keysym('Escape')),

Use r'\e' instead of '\e'.

% ruff rule W605

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure not.
The string for the escape key is esc (see higher in the list). This meant to use a special character, but \e does not resolve to anything in Python.

There are no strings in the mapping actually starting with a raw \.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read ruff rule W605 and run ruff check --select=W605 --fix on that file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware of how raw strings work, thank you.
I'm telling you I don't think r"\e" or "\\e" was a correct entry in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation warning due to invalid escape sequences in Python 3.7

2 participants