- Build:
./bin/build - Format:
poetry run black . - Lint:
poetry run flake8 . - Sort imports:
poetry run isort . - Setup pre-commit hooks:
poetry poe setup-hooks - Run unit tests (all):
nox -e unit - Run integration tests:
nox -e integration - Run specific test:
nox --force-color -e unit -p 3.10 -- tests/unit/test_file.py::TestClass::test_name - Run local tests:
./bin/test-local
- Run tests with coverage:
./bin/test-local(coverage enabled by default) - Run without coverage:
COVERAGE_ENABLED=false ./bin/test-local - Combine coverage files:
poetry run coverage combine - Generate coverage report:
poetry run coverage report - Check coverage threshold:
poetry run coverage report --fail-under=55 - Generate HTML report:
poetry run coverage html - Generate XML report:
poetry run coverage xml - Generate JSON report:
poetry run coverage json
- Follow PEP 8 with Black formatting (line length: 88)
- Use isort with Black profile for import sorting
- Use type hints consistently
- Use docstrings for all functions/classes
- Use f-strings instead of .format() for string formatting
- Use pathlib.Path for file path operations instead of os.path
- Always use
Optional[T]for parameters that can be None (notT = None) - Use explicit type hints for function parameters and return values
- Example:
def function(param: Optional[str] = None) -> str:
- Files/Functions/Variables:
snake_case - Classes:
PascalCase - Test files:
test_*.py
- Use appropriate exception types
- Log errors with context
- Handle Jupyter/IPython specific exceptions properly
- Python 3.10, 3.11, 3.12, 3.13
- Use Poetry for dependency management
- Core deps:
poetry add <package> - Dev deps:
poetry add --group dev <package> - Server deps:
poetry add --group server <package>
- Early returns to reduce nesting: Check conditions and return early
- Extract common checks into variables for readability
- Use dictionary unpacking for headers:
headers = {"Content-Type": "application/json", **auth_headers} - CLI arguments: Use space-separated format (
--port 8080)
You can run a single test using the following format:
TEST_TYPE="unit" TOOLKIT_VERSION="local-build" ./bin/test tests/unit/test_sql_execution.py::TestExecuteSql::test_execute_sql_with_connection_json_with_snowflake_encrypted_private_key