Professional Python development tools for async/await analysis and code quality
Project description
Kairix DevTools
๐ Professional Python development tools for async/await analysis, code quality, and CI/CD integration.
A comprehensive CLI library for development tools that can be used with pre-commit hooks, manually, or in CI/CD pipelines.
๐ Quick Start
# Install
pip install kairix-devtools
# Check async/await usage in your code
kairix-devtools asyncio check-await src/
# Get JSON output for tooling integration
kairix-devtools asyncio check-await src/ --output-format json
๐ Features
๐ Asyncio Analysis Tools
Advanced async/await validation that helps you catch common async programming mistakes:
- โ
Missing await detection - Finds async functions called without
await - โ Missing asyncio context - Detects async functions called outside async context
- โ
Smart asyncio.gather handling - Correctly handles coroutines passed to
gather() - โ Type-aware analysis - Respects functions typed to return coroutines
- โ Comprehensive reporting - Human-friendly and JSON output formats
๐ Documentation
๐ก Common Use Cases
1. Pre-commit Hook
Catch async/await issues before they reach your repository:
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: check-async-await
name: Check async/await usage
entry: kairix-devtools asyncio check-await
language: system
files: \.py$
args: ["--output-format", "human"]
2. CI/CD Integration
GitHub Actions example:
name: Code Quality
on: [push, pull_request]
jobs:
async-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12.x'
- name: Install kairix-devtools
run: pip install kairix-devtools
- name: Check async/await usage
run: kairix-devtools asyncio check-await src/ --output-format json
3. Local Development
Quick checks during development:
# Check specific file
kairix-devtools asyncio check-await my_async_module.py
# Check directory with exclusions
kairix-devtools asyncio check-await src/ --exclude "test_*" --exclude "*_legacy.py"
# JSON output for further processing
kairix-devtools asyncio check-await src/ --output-format json | jq '.violations | length'
๐ฏ Practical Examples
โ Issues Detected
# Missing await in async function
async def fetch_user_data():
user = get_user_async() # โ Missing await
return user
# Missing asyncio context in sync function
def main():
result = fetch_user_data() # โ Missing asyncio.run()
return result
# Unhandled coroutine
async def process_data():
fetch_data_async() # โ Created but never awaited
return "done"
โ Correct Patterns Recognized
# Proper asyncio.gather usage
async def fetch_multiple():
results = await asyncio.gather(
fetch_data_async("A"), # โ
Handled by gather
fetch_data_async("B") # โ
Handled by gather
)
return results
# Functions typed to return coroutines
def create_tasks() -> list[Coroutine[Any, Any, str]]:
return [
fetch_data_async("A"), # โ
Valid: function returns coroutines
fetch_data_async("B") # โ
Valid: function returns coroutines
]
# Proper asyncio context
def main():
result = asyncio.run(fetch_user_data()) # โ
Correct
return result
๐ง Programmatic API
Use kairix-devtools in your own Python tools:
from kairix_devtools.asyncio import AsyncChecker
# Create checker instance
checker = AsyncChecker()
# Check a single file
result = checker.check_file("my_async_code.py")
# Check a directory with exclusions
result = checker.check_directory(
"src/",
exclude_patterns=["test_*", "*_test.py"]
)
# Access results
print(f"Files checked: {result.total_files}")
print(f"Issues found: {result.violation_count}")
print(f"All checks passed: {result.passed}")
# Process violations
for violation in result.violations:
print(f"Issue in {violation.file_path}:{violation.line_number}")
print(f" Function: {violation.function_name}")
print(f" Type: {violation.violation_type}")
print(f" Code: {violation.source_line}")
# Convert to JSON for external tools
result_json = result.model_dump()
๐ Output Formats
Human-Readable Output
โ Async/await violations found!
AsyncViolationError: Function 'fetch_data' called without proper async handling
Type: missing_await
๐ก Fix: Add 'await' before the function call
๐ File "example.py", line 15
result = fetch_data("https://api.example.com")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
๐ Files checked: 3
Violations found: ๐ missing_await: 1
โ Check failed!
JSON Output
{
"total_files": 3,
"violations": [
{
"file_path": "example.py",
"line_number": 15,
"column_number": 13,
"function_name": "fetch_data",
"violation_type": "missing_await",
"source_line": " result = fetch_data(\"https://api.example.com\")"
}
],
"passed": false,
"violation_count": 1
}
๐ ๏ธ Installation & Development
Installation
# Install from PyPI (when published)
pip install kairix-devtools
# Install from source
git clone https://github.com/your-org/kairix-devtools.git
cd kairix-devtools
pip install -e .
Development Setup
# Install in development mode
pip install -e .
# Run tests
pytest tests/
# Run type checking
pyright kairix_devtools/
# Test the tool on itself
kairix-devtools asyncio check-await kairix_devtools/
๐ค Contributing
We love contributions! There are many ways you can help:
๐ Ways to Contribute
- ๐ Report Bugs - Use our issue templates
- โจ Propose Features - Share your ideas to improve the tool
- ๐ Improve Documentation - Help other users with better docs
- ๐งช Write Tests - Improve code coverage and quality
- ๐ง Development - Implement new features or fix bugs
๐ Quick Start for Contributors
# 1. Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/devtools-python.git
cd devtools-python
# 2. Set up the development environment
# This project uses a devcontainer for a consistent development environment.
# Simply open the project in VS Code with the Dev Containers extension installed.
# If you prefer a manual setup:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
# 3. Install pre-commit hooks
pre-commit install
# 4. Run tests to verify everything works
pytest
๐ Contributor Resources
- ๐ Contribution Guide - Complete step-by-step guide
- ๐ ๏ธ Development Guide - Local setup and development workflow
- ๐ Report a Bug - Template for reporting issues
- โจ Propose a Feature - Template for new ideas
- โ Ask a Question - Template to get help
๐ Acknowledgments
We thank all our contributors who make this project possible. Their contributions are featured in:
- GitHub's list of contributors
- Release notes for significant changes
- Special mentions for major contributions
๐ License
This project is licensed under the Unlicense - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 kairix_devtools-25.6.4.tar.gz.
File metadata
- Download URL: kairix_devtools-25.6.4.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
370cbb7f0e35170769da2c75882e18b08946dffac09f4cf989c0cf40c28e9eed
|
|
| MD5 |
c478c4a33fc7b8d0a55176937750b814
|
|
| BLAKE2b-256 |
0134b79c8720d9372d6bc15e62cf77bf59c697f518d45cd3954a50c4cf2ee8f2
|
Provenance
The following attestation bundles were made for kairix_devtools-25.6.4.tar.gz:
Publisher:
release.yml on kairix-dev/devtools-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kairix_devtools-25.6.4.tar.gz -
Subject digest:
370cbb7f0e35170769da2c75882e18b08946dffac09f4cf989c0cf40c28e9eed - Sigstore transparency entry: 256523022
- Sigstore integration time:
-
Permalink:
kairix-dev/devtools-python@e8ff7ea862b41d9c13e6c14d53efd337ad6941bd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kairix-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e8ff7ea862b41d9c13e6c14d53efd337ad6941bd -
Trigger Event:
push
-
Statement type:
File details
Details for the file kairix_devtools-25.6.4-py3-none-any.whl.
File metadata
- Download URL: kairix_devtools-25.6.4-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78bd6a5ee89c35f9f7ff392440fb1df3cea81a3b62d8f4042a0255af65388f0e
|
|
| MD5 |
4bb769b665519b17e7d25b2837c06783
|
|
| BLAKE2b-256 |
0220f20047a103f1d5b5b6063773e188bf2e39cec438155ff7d9a1f16a2a1cd2
|
Provenance
The following attestation bundles were made for kairix_devtools-25.6.4-py3-none-any.whl:
Publisher:
release.yml on kairix-dev/devtools-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kairix_devtools-25.6.4-py3-none-any.whl -
Subject digest:
78bd6a5ee89c35f9f7ff392440fb1df3cea81a3b62d8f4042a0255af65388f0e - Sigstore transparency entry: 256523040
- Sigstore integration time:
-
Permalink:
kairix-dev/devtools-python@e8ff7ea862b41d9c13e6c14d53efd337ad6941bd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kairix-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e8ff7ea862b41d9c13e6c14d53efd337ad6941bd -
Trigger Event:
push
-
Statement type: