-
Notifications
You must be signed in to change notification settings - Fork 2
Coding Principles and Standards
This document outlines the coding principles and standards adopted in our repository. These standards are enforced through automated checks and fixes, facilitated by the pre-commit framework. Our goal is to maintain high-quality, readable, and consistent code across the project.
We use pre-commit to automate code quality checks and fixes. This ensures that all contributions adhere to our coding standards before merging.
Below are the hooks configured in our .pre-commit-config.yaml, each serving a specific purpose in maintaining our codebase's integrity:
- YAPF (Yet Another Python Formatter): Formats Python code to conform to the PEP 8 style guide.
- isort: Sorts Python imports alphabetically, and automatically separated into sections and by type.
- Ruff: Provides rapid formatting adjustments, enforcing a consistent code style.
- Flake8: Checks against the PEP 8 guidelines, catching coding errors, and enforcing a clean codebase.
- yamllint: Lints YAML files, ensuring their syntax and structure follow best practices.
- End-of-File Fixer: Ensures that files end with a newline, a common POSIX standard.
- Mixed Line Ending: Normalizes line endings to LF, preventing cross-platform issues.
- Remove Trailing Whitespaces: Cleans up unnecessary spaces at the end of lines.
- Check toml/yaml: Validates the syntax of TOML and YAML files, respectively.
- Sort imports: Organizes imports in a consistent manner across files, improving readability.
- mdformat: Formats Markdown files to ensure they are readable and conform to the specified style guidelines.
Certain files and directories may be excluded from checks when appropriate, e.g., third-party YAML configurations specific to our dependencies.
- No Commits to Master Branch: Direct commits to the master branch are blocked to encourage review and collaboration.
Adhering to these principles and standards facilitates a robust, maintainable, and high-quality codebase. Contributors are encouraged to set up pre-commit hooks locally to ensure their contributions are compliant before submission.