# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python 3.12
brew install python@3.12
# Verify installation
python3.12 --version# Install pyenv
brew install pyenv
# Install Python 3.12
pyenv install 3.12.0
# Set local version
pyenv local 3.12.0
# Verify
python --versionpython3.12 -m venv venv
source venv/bin/activatepip install -e ".[dev]"# Activate environment
source venv/bin/activate
# Install in editable mode
pip install -e ".[dev]"
# Run tests
pytest
# Start coding!# Format code
black src tests
# Lint
ruff check src tests --fix
# Type check
pyright src
# Run tests
pytest -v
# Run with coverage
pytest --cov
# All checks
make qualitypip install pytest-watch
# Auto-run tests on file changes
ptwpip install watchdog
# Watch for changes
watchmedo shell-command \
--patterns="*.py" \
--recursive \
--command='pytest' \
src tests- Python (Microsoft)
- Pylance
- Ruff
- Pytest
{
"python.defaultInterpreterPath": "${workspaceFolder}/venv/bin/python",
"python.linting.enabled": true,
"python.linting.ruffEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["tests"]
}{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Pytest",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["${file}"],
"console": "integratedTerminal"
}
]
}git checkout -b feat/your-feature# Create test file
touch tests/unit/test_your_feature.py
# Write failing test
# Run test to verify it fails
pytest tests/unit/test_your_feature.py# Write minimal code to pass test
# Run test to verify it passes
pytest tests/unit/test_your_feature.pymake qualitygit add .
git commit -m "feat: add your feature"git push origin feat/your-feature
# Create PR on GitHubimport pdb; pdb.set_trace()from ai_project.logger import get_logger
logger = get_logger(__name__)
logger.info("Debug message", key=value)# Stop on first failure
pytest -x
# Show print statements
pytest -s
# Drop into debugger on failure
pytest --pdb
# Verbose output
pytest -vvpre-commit installpre-commit run --all-files- Trailing whitespace
- End-of-file fixer
- YAML checker
- Ruff linter
- Ruff formatter
- Mypy type checker
import cProfile
import pstats
profiler = cProfile.Profile()
profiler.enable()
# Your code here
profiler.disable()
stats = pstats.Stats(profiler)
stats.sort_stats('cumulative')
stats.print_stats(10)pip install pytest-benchmark
# Run benchmarks
pytest --benchmark-onlyLast Updated: January 15, 2026