| name | python-lint-check |
| description | Use when writing or modifying Python code to verify linting and type correctness before committing |
Python Lint & Type Check
Run ruff for linting and pyright for type checking.
Commands
# Lint with ruff
python -m ruff check .
# Auto-fix linting issues
python -m ruff check --fix .
# Type check with pyright
python -m pyright
Workflow
- After modifying Python files, run
python -m ruff check . - Fix issues or run with
--fixfor auto-fixable problems - Run
python -m pyrightfor type errors - Address any type errors before committing
Common Ruff Fixes
| Code | Issue | Fix |
|---|---|---|
| F401 | Unused import | Remove import |
| F841 | Unused variable | Remove or prefix with _ |
| E501 | Line too long | Break line or disable per-line |
| I001 | Import order | Run --fix |
Pyright Tips
- Use
# type: ignoresparingly for false positives - Add type hints to function signatures to catch more errors
- Check
pyrightconfig.jsonorpyproject.tomlfor config
Script Arguments
When modifying argparse arguments in any script, update the corresponding section in README.md to keep documentation in sync.