Skip to main content

Detect logical flow bugs in Python code using static analysis

Project description

py-flow-check

Static analyzer for logical flow bugs in Python.

It tries to catch:

  • unreachable code after return or raise
  • always true or always false conditions like if True
  • unreachable or redundant conditions in if/elif chains (best with numeric comparisons)
  • functions that do not return on every path
  • variables that might be used before assignment on some paths

Install

pip install py-flow-check

CLI

flowcheck path/to/file.py

JSON output (useful for CI):

flowcheck --json path/to/file.py

Exit code:

  • 0 if no issues
  • 1 if issues found

Python API

from flowcheck import analyze

code = """
def f(flag):
    if flag:
        x = 1
    return x
"""
for issue in analyze(code):
    print(issue.format())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_flow_check-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_flow_check-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file py_flow_check-1.0.0.tar.gz.

File metadata

  • Download URL: py_flow_check-1.0.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for py_flow_check-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b3a960dc4992f40a56433eb91268e3ef50055d48aaff31c280c248f522162611
MD5 b6f17eccdb62b7eb7faaa3dc423f6e68
BLAKE2b-256 7226f5c14da46aecf77b2f66f05caebb42fe65ff1a77de967e70f8eb5d52a177

See more details on using hashes here.

File details

Details for the file py_flow_check-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_flow_check-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for py_flow_check-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82589660dc24770be6d904d6922f508460c9713dde3dcb41242e2591e536bf7a
MD5 256cb32b5e886163614e7535366a93a9
BLAKE2b-256 0c1fe2b0a207f07e42fa99c1474d1a90258e80497e9672a194cdfeede2941f7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page