Skip to content

regex-flag-alias

Pythonstyleno fixdefault: offpython/ruff

Reports re.A, re.I, re.L, re.M, re.S, re.U and re.X, the short names of re.ASCII, re.IGNORECASE, re.LOCALE, re.MULTILINE, re.DOTALL, re.UNICODE and re.VERBOSE.

The one-letter names are hard to tell apart and to look up (re.S is DOTALL, re.M is MULTILINE). The long names say what the flag does.

To fix, write the long name.

Reported
...
...
x = re.compile("a", re.I)
python:
lint:
rules:
regex-flag-alias: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line regex-flag-alias 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 FURB167 full