Skip to main content

A tiny, modular library for common coding tasks.

Project description

๐Ÿ” codn

A powerful and intuitive toolkit for analyzing Python codebases.

PyPI version Python 3.8+ License: MIT

โœจ Features

  • ๐Ÿ“Š Project Analysis - Get comprehensive statistics about your codebase
  • ๐Ÿ” Function References - Find where functions are called across your project
  • ๐Ÿงน Import Cleanup - Detect unused imports automatically
  • ๐Ÿ“ Function Signatures - Extract detailed function information
  • ๐Ÿ—๏ธ Class Analysis - Analyze class structures and inheritance
  • โšก Fast & Reliable - Built on Python's AST for accurate analysis
  • ๐ŸŽจ Beautiful Output - Rich terminal interface with progress bars and tables

๐Ÿš€ Quick Start

Installation

Using uv (Recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install codn
uv tool install codn

Using pip

pip install codn

For Development

# Clone the repository
git clone https://github.com/dweb-lab/codn.git
cd codn

# Install with uv (recommended)
uv sync
uv run codn --help

# Or install with pip
pip install -e .

Basic Usage

# Quick project analysis (most common)
codn

# Or use the detailed commands
codn analyze project

# Simplified commands (less typing!)
codn unused              # Find unused imports
codn refs my_function    # Find function references
codn funcs               # List all functions

# Traditional verbose commands (still supported)
codn analyze unused-imports
codn analyze find-refs my_function
codn analyze functions --signatures

๐Ÿ“– Common Use Cases

๐Ÿ” Code Exploration

Understand a new codebase:

cd /path/to/project
codn --verbose          # Quick way
# or
codn analyze project --verbose

Find where a function is used:

codn refs calculate_total        # Quick way
# or
codn analyze find-refs calculate_total

๐Ÿงน Code Cleanup

Find unused imports:

codn unused                     # Quick way
# or
codn analyze unused-imports

Get function overview:

codn funcs --signatures         # Quick way
# or
codn analyze functions --signatures

โšก Git Integration

Check repository health:

codn git check --verbose

๐Ÿ’ป Python API

You can also use codn programmatically:

from codn import find_function_references, extract_function_signatures

# Find function references
code = open('my_file.py').read()
refs = find_function_references(code, 'my_function')

# Extract function signatures
signatures = extract_function_signatures(code)
for func in signatures:
    print(f"{func['name']} at line {func['line']}")

๐Ÿ“Š Example Output

Project Analysis Results
     Project Statistics
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Metric            โ”ƒ Count โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Python Files      โ”‚    25 โ”‚
โ”‚ Total Lines       โ”‚  3142 โ”‚
โ”‚ Functions         โ”‚   156 โ”‚
โ”‚ Classes           โ”‚    18 โ”‚
โ”‚ Methods           โ”‚    89 โ”‚
โ”‚ Files with Issues โ”‚     3 โ”‚
โ”‚ Unused Imports    โ”‚     7 โ”‚
โ”‚ Git Repository    โ”‚     โœ“ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽฏ Key Commands

Quick Commands (Recommended)

Command Description Example
codn Project overview (default) codn
unused Find unused imports codn unused
refs <func> Find function references codn refs main
funcs List functions and methods codn funcs --signatures

Full Commands (Traditional)

Command Description Example
analyze project Project overview and statistics codn analyze project
analyze find-refs Find function references codn analyze find-refs main
analyze unused-imports Detect unused imports codn analyze unused-imports
analyze functions List functions and methods codn analyze functions --signatures
git check Validate Git repository codn git check

๐Ÿ’ก Tip: Use quick commands to save typing! codn = codn analyze project, codn unused = codn analyze unused-imports, etc.

๐Ÿ—๏ธ Requirements

  • Python 3.8+
  • Works with any Python project
  • No configuration required

Package Manager Notes

  • uv: Recommended for faster installs and better dependency management
  • pip: Traditional option, works everywhere
  • Both methods install the same functionality

Environment Management

# With uv (handles virtual environments automatically)
uv tool install codn

# With pip in virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install codn

๐Ÿ“š Documentation

๐Ÿค Contributing

We welcome contributions! Please see our development documentation and quick development guide for details.

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ”— Links


Made with โค๏ธ for Python developers who love clean, analyzable code.

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

codn-0.1.3.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

codn-0.1.3-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file codn-0.1.3.tar.gz.

File metadata

  • Download URL: codn-0.1.3.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for codn-0.1.3.tar.gz
Algorithm Hash digest
SHA256 17772b4011163a9e69234b2630416247d0600617e354e5d30366540bb4ab8334
MD5 18af9db2ead6bd8ff4037052c3a8d49e
BLAKE2b-256 8e896d194a502df10c2e0886905658d4bd020252a165ec9d0cf86aae52d52994

See more details on using hashes here.

File details

Details for the file codn-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: codn-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for codn-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c8d30e48fba208cd34c118c5b9bcf74aa9f8452130b4494ea7cabe254abac8e2
MD5 cc4a442cacedbd285312cc0dfa4dc805
BLAKE2b-256 275b310b48ae8b5e622b6ccfabd62a226caada4789506f917bfe92aaa832bd83

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