$npx skillfedfor your agent

cognitive-complexity

Library to calculate Python functions cognitive complexity via code

With conditionsPyPI Python ModulesReleased Aug 2022352.8K downloads / moMITSource build

Decision gist · record as of 2026-08-14

sdist only — cognitive_complexity-1.3.0.tar.gz · builds from source
v1.3.0 · released 2022-08-09 · Python >=3.6

Yes, if you need cognitive complexity analysis and are comfortable with an unmaintained library. The package is stable, has no dependencies, and works reliably on Python 3.6+. However, consider it a read-only tool: expect no bug fixes, security patches, or feature updates. If active maintenance is critical for your workflow, investigate whether a maintained alternative exists before committing to this version.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.6 or later; input must be an AST node (typically from ast.parse), not raw source code.
  • High install friction: no runtime dependencies but marked as abandoned since the last commit on 2022-08-09 with no maintenance or security updates.

License · maintenance · safety

MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

last release 2022-08-09 (1466 days) · last repo commit 2022-08-09 · 47 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 352,807 downloads/mo, #7,308 on PyPI

Verify before relying

import ast
from cognitive_complexity.api import get_cognitive_complexity

funcdef = ast.parse("def f(a):\n    return a * f(a - 1)").body[0]
print(get_cognitive_complexity(funcdef))  # Output: 1
  • How closely the implementation matches G. Ann Campbell's original algorithm and whether deviations affect reliability for production linting.
  • Whether the package is maintained under a different repository or if a maintained fork exists as a drop-in replacement.
  • Current stability and compatibility with Python versions beyond 3.8 given the abandoned maintenance status.
Same gist for agents: .md · .json

What it is and what it does

Cognitive-complexity is a Python library that computes a numeric score representing how cognitively difficult a function is to understand. It works by parsing Python source code into an abstract syntax tree and applying heuristics that award complexity points for control-flow breaks, nesting depth, recursion, and logical operations. The library itself has no runtime dependencies and is typically used either as a standalone API or integrated into flake8 via the flake8-cognitive-complexity extension.

The package is based on research into cognitive complexity as a measure of code understandability—distinct from traditional cyclomatic complexity. The implementation is acknowledged to be an approximation rather than a precise realization of the original algorithm. The project has been abandoned and receives no active maintenance, though it remains functional for Python 3.6+ codebases.

Use it for

  • Integrate into a CI/CD pipeline to flag functions exceeding a complexity threshold and enforce code review for high-complexity changes.
  • Use as a flake8 plugin to get real-time warnings during development when functions become too difficult to understand.
  • Analyze legacy codebases to identify which functions are candidates for refactoring based on cognitive load.
  • Build custom linting rules that combine cognitive complexity with other metrics to guide architectural decisions.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need cognitive complexity analysis and are comfortable with an unmaintained library.

The package is stable, has no dependencies, and works reliably on Python 3.6+. However, consider it a read-only tool: expect no bug fixes, security patches, or feature updates. If active maintenance is critical for your workflow, investigate whether a maintained alternative exists before committing to this version.

Install

cognitive-complexity on PyPI

Before you install

High install friction: no runtime dependencies but marked as abandoned since the last commit on 2022-08-09 with no maintenance or security updates.

Requires Python 3.6 or later; input must be an AST node (typically from ast.parse), not raw source code.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

import ast
from cognitive_complexity.api import get_cognitive_complexity

funcdef = ast.parse("def f(a):\n    return a * f(a - 1)").body[0]
print(get_cognitive_complexity(funcdef))  # Output: 1

Verify before relying

  • How closely the implementation matches G. Ann Campbell's original algorithm and whether deviations affect reliability for production linting.
  • Whether the package is maintained under a different repository or if a maintained fork exists as a drop-in replacement.
  • Current stability and compatibility with Python versions beyond 3.8 given the abandoned maintenance status.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.6
Install frictionHigh. Source build required
Runtime dependenciesNone
MaintenanceAbandoned 1,466 days since the last release
Last repo commit
First released
Downloads352,807 / month, #7,308 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Environment :: ConsoleOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: DocumentationTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Evidence: cognitive_complexity-1.3.0.tar.gz

Tags

Capabilities
cognitive complexity measurementcode complexity analyzer pythonfunction complexity scoringcode readability metricsast-based complexity calculationmaintainability analysis toolflake8 complexity plugin
Topics
code-qualityast-analysislinting
PyPI keywords
flake8

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “cognitive complexity measurement”

Give your agent the search over MCP, or paste the wish link into any chat.

More Python Modules packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
PyYAML Worth it
PyPI · Python Modules · released Sep 2025

PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.

MITcompiled wheel · 3.8+
1.2Bdownloads / mo
pydantic Worth it
PyPI · Python Modules · released May 2026

Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.

MITpure Python · 3.9+
1.1Bdownloads / mo
annotated-types Worth it
PyPI · Python Modules · released Jul 2026

Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.

Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…

MITpure Python · 3.10+
871.3Mdownloads / mo
typing-inspection Worth it
PyPI · Python Modules · released Aug 2026

Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.

MITpure Python · 3.10+
783.0Mdownloads / mo

See also complexipy · flake8-cognitive-complexity · flake8-annotations-complexity · mccabe · flake8-expression-complexity · lizard · radon · flake8-functions · flake8 · wemake-python-styleguide