--- id: complexipy version: "7.0.1" license: MIT license_treatment: permissive maintenance: active --- # complexipy — An extremely fast Python library to calculate the cognitive complexity of Python files, written in Rust. License: permissive · Maintenance: active · Downloads: 610.3K/mo ## What it is and what it does complexipy is a Python library that measures cognitive complexity—how hard code is to understand for humans—by analyzing nesting depth, control flow patterns, and code structure. Unlike cyclomatic complexity, which counts branches, cognitive complexity penalizes nested logic and human-unfriendly patterns to reflect actual readability challenges. The library is written in Rust for speed and provides both a command-line tool and a Python API. You can use it to analyze individual files or entire codebases, set complexity thresholds, generate reports in multiple formats (JSON, CSV, SARIF, GitLab), compare complexity across git references, and integrate into CI/CD pipelines. It supports configuration via TOML files and includes pre-commit hooks, GitHub Actions, and VS Code integration. Use it for: - Enforce code quality standards in CI/CD by failing builds when functions exceed a complexity threshold - Identify the most complex functions in a codebase to prioritize refactoring efforts - Track complexity regressions in pull requests by comparing against a baseline branch - Generate SARIF reports for GitHub Code Scanning to surface maintainability issues as inline PR annotations - Integrate with pre-commit hooks to catch overly complex functions before they reach the repository ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Calculates cognitive complexity scores for Python code to measure how hard code is to understand by humans, accounting for nesting depth and control flow patterns. Yes. complexipy is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and fills a genuine need for cognitive complexity analysis in Python. The Rust backend and broad platform support (wheels for cp310, cp311, multiple architectures) reduce friction. It's suitable for teams wanting to measure and enforce code readability beyond traditional cyclomatic metrics. ## Install pip install complexipy uv add complexipy poetry add complexipy ## Installing complexipy Before you install: Medium install friction due to compiled wheels across multiple platforms (cp310, cp311, and various architectures). Active maintenance with recent release (2 days old) and 761 repository stars indicate solid ongoing support. License in practice: MIT license is permissive; you can use, modify, and distribute complexipy with minimal restrictions, making it suitable for both open-source and commercial projects. Quickstart: pip install complexipy from complexipy import file_complexity result = file_complexity("app.py") print(f"File complexity: {result.complexity}") for func in result.functions: print(f"{func.name}: {func.complexity}") Verify before relying: - Whether the Rust implementation provides measurable performance gains over pure-Python alternatives in typical workflows - How cognitive complexity scores correlate with actual maintenance burden or bug rates in practice ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 610.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cognitive complexity analysis python, code readability metrics, python code quality measurement, maintainability scoring tool, nesting depth analysis, human comprehension metrics, static code analysis, code-quality, static-analysis, ci-cd [View on SkillFed](https://skillfed.io/packages/complexipy) · [View on PyPI](https://pypi.org/project/complexipy/)