A tiny, modular library for common coding tasks.
Project description
๐ codn
A powerful and intuitive toolkit for analyzing Python codebases.
โจ 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
- CLI User Guide - Complete command reference
- API Documentation - Python API reference
- Examples - Code examples and use cases
- Development - Contributing and development setup
๐ค Contributing
We welcome contributions! Please see our development documentation and quick development guide for details.
๐ License
MIT License - see LICENSE file for details.
๐ Links
- PyPI: https://pypi.org/project/codn/
- Source Code: https://github.com/dweb-lab/codn
- Issue Tracker: https://github.com/dweb-lab/codn/issues
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17772b4011163a9e69234b2630416247d0600617e354e5d30366540bb4ab8334
|
|
| MD5 |
18af9db2ead6bd8ff4037052c3a8d49e
|
|
| BLAKE2b-256 |
8e896d194a502df10c2e0886905658d4bd020252a165ec9d0cf86aae52d52994
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8d30e48fba208cd34c118c5b9bcf74aa9f8452130b4494ea7cabe254abac8e2
|
|
| MD5 |
cc4a442cacedbd285312cc0dfa4dc805
|
|
| BLAKE2b-256 |
275b310b48ae8b5e622b6ccfabd62a226caada4789506f917bfe92aaa832bd83
|