pydiatra (github) is yet another static checker for Python code.
Among other checks pydiatra offers number of regexp checks which are hard to find within other analyzers:
- duplicate range (e.g. re.compile("[aa]"))
- overlapping ranges (e.g. re.compile("[a-zA-z]"))
- bad escape sequences (e.g. re.compile(r"\eggs"))
- misplaced inline flags (e.g. re.compile("eggs(?i)"); Python 3.6+ only)
- combining incompatible flags
- redundant flags
- misplaced flags arguments in re.split(), re.sub(), re.subn()
And some other nice to have checks:
- invalid escape sequences in strings (Python 3.6+ only)
- hardcoded errno values (e.g. exc.errno == 2 instead of exc.errno == errno.ENOENT)
For complete list of implemented checks consult pydiatra page.
Below is list of checks supported by this plugin:
PYD001
assertion always truePYD002
async await used as namePYD003
embedded code copyPYD004
except shadows builtinPYD005
bare exceptPYD006
hardcoded errno valuePYD007
inconsistent indentationPYD008
mkstemp file descriptor leakPYD009
obsolete pil importPYD010
py3k compat warningPYD011
regexp bad escapePYD012
regexp duplicate rangePYD013
regexp incompatible flagsPYD014
regexp misplaced inline flagsPYD015
regexp misplaced flags argumentPYD016
regexp overlapping rangesPYD017
regexp redundant flagPYD018
regexp syntax errorPYD019
regexp syntax warningPYD020
string exceptionPYD021
string formatting errorPYD022
syntax errorPYD023
syntax warningPYD024
sys.hexversion comparisonPYD025
sys.version comparison
This plugin uses PYD0
as violation class. Add it to flake8's select
to enable.
flake8 --select PYD0 .