- Use 4 spaces for indentation
- Maximum line length: 79 characters (Black default)
- Format code with Black:
black microimpute/ - Sort imports with isort:
isort microimpute/ - IMPORTANT: All files must end with a newline character
- This is enforced by the
linechecktool in CI - Run
make check-formatlocally before pushing to catch these errors
- This is enforced by the
- Use snake_case for variables, functions, and modules
- Use CamelCase for classes
- Constants should be UPPERCASE
- Add type hints to all function parameters and return values
- Document functions with ReStructuredText-style docstrings
- Group imports: standard library, third-party, local modules
- Import specific functions/classes rather than entire modules when practical
- Use assertions for validation
- Raise appropriate exceptions with informative messages
- Add context to exceptions when re-raising
- Always run formatting tools:
make format- This runs Black, isort, and linecheck
- Fixes most formatting issues automatically
- Check your formatting:
make check-format- Ensures your code will pass CI linting checks
- Run tests locally:
make test- Catch test failures before CI
- Check for trailing newlines: All files must end with a newline
- The linecheck tool will catch this
- Linting failures: Run
make formatto fix - Missing trailing newlines: Run
make formator add manually - Import order issues: Run
isort microimpute/ - Line length issues: Run
black microimpute/ --line-length 79
- NEVER HARDCODE LOGIC JUST TO PASS SPECIFIC TEST CASES
- This undermines code quality and model integrity
- It creates technical debt and maintenance nightmares
- It destroys the ability to trust results
- Never add conditional logic that returns fixed values for specific input combinations