Skip to content

unicode-literal

Pythonstyleno fixdefault: offpython/ruff

Reports a string with the u prefix.

In Python 3 every str is Unicode, so u"text" and "text" are the same. The prefix was needed to bridge Python 2.

To fix, remove the u.

Reported
...
pass
x = u"a" "b"
y = f(u"a", "b")
try:
pass
...
python:
lint:
rules:
unicode-literal: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line unicode-literal in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff UP025 full