Dlint

raw JSON →
0.16.0 verified Mon Apr 27 auth: no python

Dlint is a security-focused linter for Python that enforces best coding practices and helps prevent common vulnerabilities. The latest version is 0.16.0, compatible with Python 3.8.1 to 3.11. It is actively maintained with ongoing releases.

pip install dlint
error ModuleNotFoundError: No module named 'dlint'
cause Dlint is not installed or installed in a different Python environment.
fix
Ensure Dlint is installed: pip install dlint. Check that you're using the correct Python interpreter (e.g., virtualenv).
error flake8: error: unrecognized arguments: --select=DUO
cause Dlint is not installed or not properly configured as a flake8 plugin.
fix
Install dlint: pip install dlint. Then run flake8 --select=DUO. If still failing, check flake8 plugin installation paths.
error AttributeError: module 'dlint' has no attribute 'lint_run'
cause Using an older version of dlint (<0.12.0) where lint_run was not the public API.
fix
Upgrade to latest dlint: pip install --upgrade dlint. Or use the old API: from dlint import run (if version <0.12.0).
breaking Dlint 0.14.0 removed the 'dlint' CLI command; use flake8 with dlint plugin instead.
fix Run 'flake8 --select=DUO' instead of 'dlint'.
deprecated The 'plugins' argument to lint_run is deprecated; use 'allowed_codes' instead.
fix Specify 'allowed_codes' instead of 'plugins'.
gotcha Dlint codes (e.g., DUO123) are not dynamically loaded; you must restart your linter after installing dlint.
fix Restart your editor or re-run flake8 after pip install dlint.
gotcha If using flake8, ensure you have the 'dlint' package installed and use '--select=DUO' to enable Dlint rules.
fix pip install dlint && flake8 --select=DUO your_code.py

Run Dlint on a string of Python code and print out any security issues found.

from dlint import lint_run
import os
code = "import os; os.system('ls')"
result = lint_run(code, plugins=None, ignore=[], allowed_codes=[])
for issue in result:
    print(issue.linter_code, issue.message)