* Add pre-commit hooks to match CI pipeline linting rules * Add pre-commit hooks that match GitHub CI pipeline exactly * Ran lint check
3.2 KiB
Contributing to Vocalinux
Thank you for your interest in contributing to Vocalinux! This document provides guidelines and instructions for contributing to the project.
Development Environment Setup
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/vocalinux.git cd vocalinux - Set up the development environment:
# Install development dependencies pip install -e ".[dev]" # Install pre-commit hooks pip install pre-commit pre-commit install
Pre-commit Hooks
We use pre-commit hooks to ensure code quality and consistency. These hooks automatically run before each commit to check your code against our standards.
Pre-commit Configuration
The pre-commit configuration in .pre-commit-config.yaml includes:
- black: Code formatter (line length: 100)
- isort: Import sorter (configured to be compatible with black)
- flake8: Linter with plugins for docstrings, comprehensions, and bug detection
- Additional checks: Trailing whitespace, file endings, YAML/JSON validation, etc.
Running Pre-commit Manually
You can run the pre-commit checks manually on all files:
pre-commit run --all-files
Or on specific files:
pre-commit run --files path/to/file1.py path/to/file2.py
Bypassing Pre-commit (Emergency Only)
In emergency situations only, you can bypass pre-commit hooks:
git commit -m "Your message" --no-verify
However, this is strongly discouraged as it may lead to CI pipeline failures.
Code Style Guidelines
We follow these code style conventions:
-
PEP 8: With modifications:
- Maximum line length: 100 characters
- Use Black formatting
-
Docstrings: All public methods, classes, and modules should have docstrings
-
Imports: Organized using isort with the following sections:
- Standard library imports
- Third-party imports
- Local application imports
-
Type Annotations: Use type hints where appropriate
Testing
Write tests for all new features and bug fixes:
# Run tests
pytest
# Run tests with coverage report
pytest --cov=src
Aim for at least 80% test coverage for new code.
Pull Request Process
- Ensure all pre-commit checks pass
- Update documentation if necessary
- Add or update tests as needed
- Create a pull request with a clear description of the changes
- Link any related issues
- Wait for code review
Commit Message Guidelines
Follow these guidelines for commit messages:
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests after the first line
Example:
Add voice command for deleting sentences
This implements the "delete that" command functionality
to remove the last sentence entered by the user.
Fixes #123
Documentation
Update documentation for any new features or changes:
- Add docstrings to new functions, classes, and methods
- Update README.md or relevant docs in the docs/ directory
- Add or update code examples if applicable
Thank you for contributing to Vocalinux!