pydiatra is yet another static checker for Python code.
- embedded code copies
except
shadowing builtins (e.g.except IOError, OSError:
, which overwritesOSError
)- bare
except
(i.e.except:
) - hardcoded errno values
(e.g.
exc.errno == 2
instead ofexc.errno == errno.ENOENT
) - inconsistent use of tabs and spaces in indentation
mkstemp()
file descriptor leaks (e.g.path = tempfile.mkstemp()[1]
)- obsolete PIL imports
(e.g.
import Image
instead offrom PIL import Image
) - regular expression syntax errors
- misplaced flags arguments in
re.split()
,re.sub()
,re.subn()
- dubious or deprecated constructs in regular expressions:
- 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
- duplicate range
(e.g.
- string exceptions
(e.g.
raise "eggs"
orexcept "ham":
) - string formatting errors
- comparisons with
sys.version
orsys.hexversion
- Python syntax errors
- Python syntax warnings
- assertions that are always true
- syntactic constructs that are no longer supported in Python 3
- ill-formed assignments to global variables
- use of
async
andawait
as names - invalid escape sequences in strings (Python 3.6+ only)
See the manual page for details.
- Python 2.7 or 3.2+
- futures (needed only for Python 2.X)