Thank you for your interest in contributing to this project! We welcome contributions from the community and appreciate your efforts to improve the project.
- Getting Started
- Pre-commit Hooks Setup
- How to Contribute
- Code Style Guidelines
- Testing Requirements
- Pull Request Process
- Issue References
- Community Standards
- Running Tests
- Fork the repository by clicking the "Fork" button at the top right of the repository page
- Clone your forked repository to your local machine:
git clone https://github.com/YOUR_USERNAME/mom.git cd mom - Add the original repository as an upstream remote:
git remote add upstream https://github.com/dhanvina/mom.git
Always create a new branch for your work. Never commit directly to the main branch.
git checkout -b feature/your-feature-nameBranch naming conventions:
feature/- for new featuresbugfix/- for bug fixeshotfix/- for urgent fixesdocs/- for documentation changesrefactor/- for code refactoring
This project uses pre-commit hooks to ensure code quality and consistency. These hooks automatically run checks before each commit to catch issues early.
-
Install pre-commit (if you haven't already):
# Using pip pip install pre-commit # Using conda conda install -c conda-forge pre-commit # Using homebrew (macOS) brew install pre-commit
-
Install the git hook scripts:
pre-commit install
-
Verify installation:
pre-commit --version
Our .pre-commit-config.yaml includes several tools that will automatically run on your code:
- Black: Automatically formats Python code to ensure consistent style
- isort: Sorts and organizes import statements
- Flake8: Checks for Python syntax errors and style issues
- Bandit: Scans for common security issues
- MyPy: Performs static type checking
- General hooks: Check for trailing whitespace, file endings, YAML syntax, etc.
-
Run on all files:
pre-commit run --all-files
-
Run on staged files only (what happens during commit):
pre-commit run
-
Run a specific hook:
pre-commit run black pre-commit run flake8
Once installed, pre-commit hooks run automatically:
- Before each commit: Hooks run on staged files
- If any hook fails: The commit is blocked until issues are fixed
- Auto-fixes: Some hooks (like Black, isort) automatically fix issues
In rare cases where you need to skip hooks:
# Skip all hooks
git commit -m "your message" --no-verify
# Skip specific hooks
SKIP=flake8,mypy git commit -m "your message"Note: Skipping hooks is discouraged as it bypasses quality checks.
- Hook installation issues: Try
pre-commit cleanthenpre-commit install - Outdated hooks: Run
pre-commit autoupdateto update hook versions - Cache issues: Use
pre-commit cleanto clear the cache
- Find or create an issue: Before starting work, check if an issue exists for what you want to do. If not, create one to discuss your proposed changes.
- Fork and branch: Fork the repository and create a feature branch from
main. - Set up pre-commit hooks: Follow the Pre-commit Hooks Setup guide above.
- Make your changes: Implement your feature or fix with clear, commented code.
- Write/modify tests: Ensure your changes are covered by tests (see Testing Requirements).
- Test locally: Run all tests locally to ensure nothing is broken (see Running Tests).
- Run pre-commit checks: Ensure all pre-commit hooks pass before committing.
- Commit your changes: Use clear, descriptive commit messages.
- Push to your fork: Push your branch to your forked repository.
- Submit a pull request: Create a PR against the main repository's
mainbranch. - Respond to feedback: Address any review comments promptly.
We follow PEP 8 with some modifications:
- Use Black for formatting (configured in
.pre-commit-config.yaml) - Maximum line length: 88 characters (Black's default)
- Use isort for import organization
- Use type hints where appropriate
- Write clear, self-documenting code
- Add comments for complex logic
- Use descriptive variable and function names
- Follow existing patterns in the codebase
- Write unit tests for new features
- Maintain or improve test coverage
- Test edge cases and error conditions
- Use descriptive test names
def test_descriptive_name():
# Arrange
# Set up test data
# Act
# Execute the code being tested
# Assert
# Verify the results- ✅ All tests pass locally
- ✅ Pre-commit hooks pass
- ✅ Code follows style guidelines
- ✅ Documentation is updated (if applicable)
- ✅ Commit messages are clear
Your PR should include:
- What: Description of changes
- Why: Reason for changes
- How: Approach taken
- Testing: How you tested the changes
- Related Issues: Link to relevant issues
- PRs require at least one approving review
- Address all review comments
- Keep PRs focused and reasonably sized
- Be responsive to feedback
When referencing issues in commits or PRs:
Fixes #123- Closes the issue automaticallyCloses #123- Also closes the issueRelated to #123- Links without closingAddresses #123- Links without closing
- Be respectful and inclusive
- Welcome newcomers
- Provide constructive feedback
- Focus on the code, not the person
- Use clear, professional language
- Be patient with contributors
- Ask questions when unclear
- Share knowledge and help others
pytestpytest tests/test_specific.pypytest --cov=mom --cov-report=htmlpytest -vThank you for contributing to mom! Your efforts help make this project better for everyone. 🎉