chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
# Python Linter
|
||||
|
||||
Run Python code linting and formatting tools.
|
||||
|
||||
## Purpose
|
||||
|
||||
This command helps you maintain code quality using Python's best linting and formatting tools.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/lint
|
||||
```
|
||||
|
||||
## What this command does
|
||||
|
||||
1. **Runs multiple linters** (flake8, pylint, black, isort)
|
||||
2. **Provides detailed feedback** on code quality issues
|
||||
3. **Auto-fixes formatting** where possible
|
||||
4. **Checks type hints** if mypy is configured
|
||||
|
||||
## Example Commands
|
||||
|
||||
### Black (code formatting)
|
||||
```bash
|
||||
# Format all Python files
|
||||
black .
|
||||
|
||||
# Check formatting without changing files
|
||||
black --check .
|
||||
|
||||
# Format specific file
|
||||
black src/main.py
|
||||
```
|
||||
|
||||
### flake8 (style guide enforcement)
|
||||
```bash
|
||||
# Check all Python files
|
||||
flake8 .
|
||||
|
||||
# Check specific directory
|
||||
flake8 src/
|
||||
|
||||
# Check with specific rules
|
||||
flake8 --max-line-length=88 .
|
||||
```
|
||||
|
||||
### isort (import sorting)
|
||||
```bash
|
||||
# Sort imports in all files
|
||||
isort .
|
||||
|
||||
# Check import sorting
|
||||
isort --check-only .
|
||||
|
||||
# Sort imports in specific file
|
||||
isort src/main.py
|
||||
```
|
||||
|
||||
### pylint (comprehensive linting)
|
||||
```bash
|
||||
# Run pylint on all files
|
||||
pylint src/
|
||||
|
||||
# Run with specific score threshold
|
||||
pylint --fail-under=8.0 src/
|
||||
|
||||
# Generate detailed report
|
||||
pylint --output-format=html src/ > pylint_report.html
|
||||
```
|
||||
|
||||
### mypy (type checking)
|
||||
```bash
|
||||
# Check types in all files
|
||||
mypy .
|
||||
|
||||
# Check specific module
|
||||
mypy src/models.py
|
||||
|
||||
# Check with strict mode
|
||||
mypy --strict src/
|
||||
```
|
||||
|
||||
## Configuration Files
|
||||
|
||||
Most projects benefit from configuration files:
|
||||
|
||||
### .flake8
|
||||
```ini
|
||||
[flake8]
|
||||
max-line-length = 88
|
||||
exclude = .git,__pycache__,venv
|
||||
ignore = E203,W503
|
||||
```
|
||||
|
||||
### pyproject.toml
|
||||
```toml
|
||||
[tool.black]
|
||||
line-length = 88
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Run linters before committing code
|
||||
- Use consistent formatting across the project
|
||||
- Fix linting issues promptly
|
||||
- Configure linters to match your team's style
|
||||
- Use type hints for better code documentation
|
||||
@@ -0,0 +1,73 @@
|
||||
# Test Runner
|
||||
|
||||
Run Python tests with pytest, unittest, or other testing frameworks.
|
||||
|
||||
## Purpose
|
||||
|
||||
This command helps you run Python tests effectively with proper configuration and reporting.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/test
|
||||
```
|
||||
|
||||
## What this command does
|
||||
|
||||
1. **Detects test framework** (pytest, unittest, nose2)
|
||||
2. **Runs appropriate tests** with proper configuration
|
||||
3. **Provides coverage reporting** if available
|
||||
4. **Shows clear test results** with failure details
|
||||
|
||||
## Example Commands
|
||||
|
||||
### pytest (recommended)
|
||||
```bash
|
||||
# Run all tests
|
||||
pytest
|
||||
|
||||
# Run with coverage
|
||||
pytest --cov=src --cov-report=html
|
||||
|
||||
# Run specific test file
|
||||
pytest tests/test_models.py
|
||||
|
||||
# Run with verbose output
|
||||
pytest -v
|
||||
|
||||
# Run tests matching pattern
|
||||
pytest -k "test_user"
|
||||
```
|
||||
|
||||
### unittest
|
||||
```bash
|
||||
# Run all tests
|
||||
python -m unittest discover
|
||||
|
||||
# Run specific test file
|
||||
python -m unittest tests.test_models
|
||||
|
||||
# Run with verbose output
|
||||
python -m unittest -v
|
||||
```
|
||||
|
||||
### Django tests
|
||||
```bash
|
||||
# Run all Django tests
|
||||
python manage.py test
|
||||
|
||||
# Run specific app tests
|
||||
python manage.py test myapp
|
||||
|
||||
# Run with coverage
|
||||
coverage run --source='.' manage.py test
|
||||
coverage report
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Write tests for all critical functionality
|
||||
- Use descriptive test names
|
||||
- Keep tests isolated and independent
|
||||
- Mock external dependencies
|
||||
- Aim for high test coverage (80%+)
|
||||
Reference in New Issue
Block a user