When making changes to the codebase, follow this workflow to ensure code quality:
Before making any code changes, run the linter to establish a baseline:
./scripts/lintThis runs:
pyright- Type checkingmypy- Additional type checkingruff check- Code lintingruff format --check- Format checking- Import validation
Make the necessary code changes, ensuring you:
- Follow existing code patterns
- Update type annotations
- Handle edge cases (e.g.,
Omit,NotGiven,None) - Maintain backward compatibility
Update or add tests for your changes:
- Unit tests in
tests/ - Smoke tests in
tests/smoketests/ - Ensure tests match the new behavior
After making changes, run the linter again to catch any issues:
./scripts/lintFix any new errors or warnings that appear.
Apply code formatting to ensure consistent style:
ruff format .This auto-formats all Python files to match the project's style guidelines.
Run the test suite to ensure everything works:
# Run all tests
uv run pytest
# Run specific tests
uv run pytest tests/test_axon_sse_reconnect.py -xvs
# Run smoke tests
uv run pytest tests/smoketests/ -m smoketestOnce lint, format, and tests pass, commit your changes:
git add -A
git commit -m "type: description
Detailed explanation of changes
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"When dealing with parameters that can be omitted:
# Parameter definition
def method(self, param: int | Omit = omit):
...
# In implementation, check for Omit before using
if not isinstance(param, Omit):
use_param(param)
else:
# param was omitted, use default behavior
passThe transform function automatically filters out Omit and NotGiven values:
# This dict with omitted values
{"field": omit, "other": 123}
# Becomes this after transform
{"other": 123}When testing methods that call _get or similar:
with patch.object(client.resource, "_get") as mock_get:
mock_stream = Mock(spec=Stream)
mock_get.return_value = mock_stream
# Your test code
result = client.resource.method()
# Verify the call
call_args = mock_get.call_args
options = call_args.kwargs["options"]
assert options["params"]["field"] == expected_valueWhen merging branches:
- Understand both changes - Read the diff from both sides
- Combine features intelligently - Don't just pick one side
- Update tests - Tests may need adjustments for merged behavior
- Fix type errors - Merges can introduce type mismatches
- Validate syntax - Run
python3 -m py_compileon changed files - Run full lint - Ensure everything passes
The merge of origin/main into feature/ts-pr-765-port required:
- Code fix - Handle
Omittype properly in reconnection logic - Test fix - Update assertions from
is Nonetonot in dict - Syntax check - Verify Python syntax is valid
- Type check - Ensure mypy/pyright pass
See commit history for the resolution pattern.