{"library":"pyflakes","title":"Pyflakes: Python Static Code Analysis","description":"Pyflakes is a fast, lightweight static analysis tool that meticulously checks Python code for common programming errors without executing it. It primarily identifies issues such as unused imports, undefined names, and redefined variables. Focusing solely on error detection, rather than code style, it aims for speed and minimizes false positives. Currently at version 3.4.0, Pyflakes supports Python 3.9 and newer, and is actively maintained by the PyCQA organization.","language":"python","status":"active","last_verified":"Sat Apr 11","install":{"commands":["pip install pyflakes"],"cli":{"name":"pyflakes","version":"3.4.0 Python 3.11.15 on Linux"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport os\n\n# Create a dummy Python file with an error\ncode_to_check = \"\"\"\nimport os\n\ndef my_func():\n    x = 10\n    # y is used but not defined, 'os' is imported but unused\n    print(y)\n\"\"\"\n\nfile_path = \"temp_code.py\"\nwith open(file_path, \"w\") as f:\n    f.write(code_to_check)\n\n# Run pyflakes on the file\ntry:\n    result = subprocess.run(\n        [\"pyflakes\", file_path],\n        capture_output=True,\n        text=True,\n        check=False  # pyflakes exits with non-zero on errors\n    )\n    print(\"Pyflakes Output:\\n\" + result.stdout)\n    if result.stderr:\n        print(\"Pyflakes Error (stderr):\\n\" + result.stderr)\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(file_path):\n        os.remove(file_path)\n\n# Expected output might look like:\n# temp_code.py:2: 'os' imported but unused\n# temp_code.py:6: undefined name 'y'","lang":"python","description":"Demonstrates how to run Pyflakes from the command line on a Python file to detect errors. Pyflakes outputs issues to stdout.","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","last_tested":"2026-04-23","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]},"compatibility":null}