pyflakes

Fast Python source code checker for logical errors — detects undefined names, unused imports, redefined names, and other logical errors without style enforcement. pyflakes features: undefined variable/name detection, unused import detection, redefined function/variable warnings, import shadowing detection, __all__ export validation, Python 2/3 compatible syntax checking, programmatic API via pyflakes.api, direct AST analysis (no execution), extremely fast (no type inference), flake8 plugin integration, and zero false positives policy (no style warnings). Focused exclusively on logical errors, not style.

Evaluated Mar 06, 2026 (0d ago) v3.x
Homepage ↗ Repo ↗ Developer Tools python pyflakes linter static-analysis imports undefined unused
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
92
/ 100
Is it safe for agents?
⚡ Reliability
90
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
82
Error Messages
85
Auth Simplicity
99
Rate Limits
99

🔒 Security

TLS Enforcement
92
Auth Strength
92
Scope Granularity
90
Dep. Hygiene
92
Secret Handling
92

Static analysis library with no network calls and minimal dependencies. Analyzing untrusted code: pyflakes parses AST without executing — safe. No side effects from analysis. Minimal attack surface.

⚡ Reliability

Uptime/SLA
88
Version Stability
90
Breaking Changes
90
Error Recovery
90
AF Security Reliability

Best When

Fast logical error checking without style opinions — pyflakes is ideal for CI gates that catch undefined names and unused imports without generating style noise.

Avoid When

Style enforcement needed (use ruff/flake8), type checking (use mypy), comprehensive static analysis (use pylint), or when zero false positives is less important than finding more issues.

Use Cases

  • Agent code validation — from pyflakes import api; import ast; tree = ast.parse(source_code); result = api.check(source_code, '<string>'); print(result) — check code; agent validates generated Python code for logical errors before execution; result is count of warnings; output to stdout; returns 0 on clean code
  • Agent file linting — from pyflakes.api import main; import sys; sys.argv = ['pyflakes', 'myfile.py']; main() — lint file; agent checks Python file for undefined names and unused imports; programmatic invocation via sys.argv manipulation; better: use subprocess for isolation
  • Agent import analysis — from pyflakes import api, checker; tree = ast.parse(source); w = checker.Checker(tree, '<test>'); for warning in w.messages: print(type(warning).__name__, warning.lineno, warning.message_args) — structured warnings; agent analyzes imports and undefined names programmatically; warning types: UndefinedName, UnusedImport, RedefinedWhileUnused
  • Agent flake8 integration — pyflakes integrates as flake8 plugin automatically when both installed; flake8 myfile.py reports pyflakes F-codes; F401=unused import, F811=redefined, F821=undefined name; agent runs flake8 to get combined style+logic checks; pyflakes adds F-codes to flake8 output
  • Agent CI code gate — import subprocess; result = subprocess.run(['pyflakes', 'src/'], capture_output=True); if result.returncode != 0: raise ValueError(f'pyflakes errors:\n{result.stdout.decode()}') — gate check; agent CI pipeline rejects code with undefined names or unused imports; faster than pylint for pure logical checks

Not For

  • Style checking — pyflakes explicitly does not check style; for PEP 8 use flake8/ruff/pycodestyle
  • Type checking — pyflakes doesn't do type inference; for type errors use mypy/pyright
  • Complex static analysis — pyflakes checks limited set of issues; for comprehensive analysis use pylint

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — local static analysis library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

pyflakes is MIT licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • api.check() return value is warning count not bool — from pyflakes.api import check; result = check(code, '<string>'); result is integer (0 = clean, >0 = warnings found); agent code checking success: if check(code, '<string>') == 0: code_is_clean; output goes to stdout/stderr not return value; redirect sys.stdout to capture messages
  • pyflakes ignores noqa comments — pyflakes does not respect # noqa inline comments (that's a flake8 feature); to suppress pyflakes warnings programmatically, restructure code; for noqa support, run via flake8 --select=F instead of pyflakes directly; agent code using noqa suppression must run through flake8
  • Checker API requires compiled AST — from pyflakes.checker import Checker; Checker(ast.parse(source), '<name>') — requires ast.parse() result not raw string; api.check(source_string) handles parsing internally; agent code using Checker directly must parse first and handle SyntaxError from ast.parse separately
  • pyflakes does not understand __all__ magic in all cases — __all__ = ['exported_name'] marks names as used; but dynamic __all__ = [x for x in dir()] doesn't prevent unused-import warnings; agent code with dynamic __all__ may see false positives; suppress by using static __all__ list
  • Unused imports in __init__.py trigger warnings — pyflakes warns about unused imports even in __init__.py re-exports; from package.module import Something triggers UnusedImport if Something not used locally; workaround: from package.module import Something as Something (explicit re-export pattern) or add to __all__
  • No configuration file support — pyflakes has zero configuration; cannot ignore specific error codes or paths; for project-level ignore rules, use flake8 with per-file-ignores in setup.cfg; agent code needing selective suppression must use flake8+pyflakes not standalone pyflakes

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for pyflakes.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered