Thank you for your interest in contributing to X12 EDI Tools! This document provides guidelines and instructions for contributing.
Be respectful, inclusive, and constructive. We're all here to build great software.
- Python 3.10+
- Git
# Clone the repository
git clone https://github.com/donjohnson/x12-edi-tools.git
cd x12-edi-tools
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install with dev dependencies
pip install -e ".[dev]"This project follows strict TDD. All code changes must follow the RED-GREEN-REFACTOR cycle:
- RED: Write a failing test first
- GREEN: Write minimal code to make it pass
- REFACTOR: Clean up while keeping tests green
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=x12 --cov-report=term-missing
# Run specific test types
pytest tests/unit -v
pytest tests/integration -v
pytest tests/property -v
pytest tests/compliance -v
pytest tests/performance -vBefore submitting, ensure your code passes all quality checks:
# Linting
ruff check x12/
ruff format x12/
# Type checking
mypy x12/ --strictfeat/description- New featuresfix/description- Bug fixesdocs/description- Documentationrefactor/description- Code refactoringtest/description- Test additions/changes
Use Conventional Commits:
feat: add 837D dental claim support
fix: handle empty trailing elements in segment parser
test: add property tests for roundtrip invariants
docs: update README with streaming examples
refactor: extract loop builder from parser
- Fork the repository
- Create a feature branch from
main - Write tests for your changes (TDD!)
- Implement your changes
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request
- Tests written and passing
- Coverage maintained (≥80%)
- Code passes
ruff check - Type hints added for public APIs
- Docstrings for public functions/classes
- CHANGELOG.md updated (if applicable)
tests/
├── unit/ # Fast, isolated tests
├── integration/ # Multi-component tests
├── property/ # Hypothesis property tests
├── compliance/ # Standards compliance
└── performance/ # Benchmarks
@pytest.mark.unit
class TestMyFeature:
"""Tests for my feature."""
def test_basic_functionality(self):
"""Must do the basic thing."""
result = my_function()
assert result == expected
def test_edge_case(self):
"""Must handle edge case."""
with pytest.raises(ValueError):
my_function(invalid_input)- Minimum 80% overall coverage
- 100% coverage for public APIs
- No real patient data (PHI) in tests
- Use synthetic/fake data only
- Follow PEP 8
- Line length: 100 characters
- Use type hints for all public APIs
- Use Google-style docstrings
def parse_segment(
content: str,
delimiters: Delimiters,
strict: bool = False,
) -> Segment:
"""Parse an EDI segment from string content.
Args:
content: Raw EDI segment string.
delimiters: Delimiter configuration.
strict: If True, raise on validation errors.
Returns:
Parsed Segment object.
Raises:
ParseError: If content cannot be parsed.
"""- Add schema in
x12/schema/loader.py - Add models in
x12/transactions/ - Add tests in
tests/unit/ - Update README if significant
- Add to
x12/codes/registry.py - Add tests in
tests/unit/test_codes.py
- Open an issue for bugs or feature requests
- Start a discussion for questions
By contributing, you agree that your contributions will be licensed under the MIT License.