PEP 561 Type Distribution Workflow
The type-check.yml workflow ensures that the Slack MCP Server properly distributes type information according to PEP 561 standards.
Triggers:
- Push to master: When type distribution files are modified
- Pull requests to master: For PEP 561 compliance validation before merge
- Manual dispatch: On-demand validation via workflow dispatch
Purpose: Validates PEP 561 compliance for type information distribution in Python packages.
Note: MyPy type checking of source code is handled by pre-commit hooks (configured in .pre-commit-config.yaml). This workflow focuses exclusively on PEP 561 compliance - ensuring type information is properly packaged and distributed.
Overviewâ
This workflow validates type information distribution:
- đ PEP 561 Compliance - Validates proper type information packaging and distribution
- đĻ Type Imports - Ensures type definitions are accessible and functional after installation
- đ Distribution Verification - Confirms type files are included in built packages
Workflow Jobsâ
1. PEP 561 Compliance Verification (verify-pep561-compliance)â
Validates that the package correctly implements PEP 561 standards for distributing type information with Python packages.
Purpose: Ensures type checkers can automatically discover and use the package's type information after installation.
Validation Process:
Step 1: Marker File Validation
# Verify py.typed marker file exists
if [ ! -f "slack_mcp/py.typed" ]; then
echo "â Error: py.typed marker file not found!"
exit 1
fi
â
py.typed marker file exists
Step 2: Type Module Validation
# Verify types.py module and exports
â
types.py module exists
â
types.py has __all__ export
Step 3: Build Configuration Validation
# Verify pyproject.toml includes type artifacts
â
pyproject.toml includes py.typed in artifacts
Step 4: Distribution Verification
# Build package and verify type files in distributions
uv build --sdist --wheel
# Check source distribution
â
py.typed found in source distribution
â
types.py found in source distribution
# Check wheel distribution
â
py.typed found in wheel distribution
â
types.py found in wheel distribution
PEP Standards Validated:
- PEP 561 - Distributing and Packaging Type Information
- PEP 484 - Type Hints
- PEP 585 - Type Hinting Generics
- PEP 544 - Protocols (Structural Subtyping)
- PEP 695 - Type Parameter Syntax (Python 3.12+)
2. Type Import Testing (test-type-imports)â
Validates that type definitions are correctly exported and accessible for use in application code.
Purpose: Ensures the type system is functional and all type definitions can be imported and used as intended after package installation.
Test Categories:
Module Import Validation
from slack_mcp import types
â
Successfully imported types module
â
Available types: 23 exports
SlackEvent Enum Validation
from slack_mcp import SlackEvent
â
Successfully imported SlackEvent
â
Total events: 99
Type Accessibility Testing
The workflow validates that all major type categories are accessible:
# JSON type definitions
assert hasattr(types, 'JSONValue')
assert hasattr(types, 'JSONDict')
assert hasattr(types, 'JSONList')
assert hasattr(types, 'JSONPrimitive')
â
JSON types accessible
# Slack-specific types
assert hasattr(types, 'SlackChannelID')
assert hasattr(types, 'SlackUserID')
assert hasattr(types, 'SlackTimestamp')
assert hasattr(types, 'SlackToken')
assert hasattr(types, 'SlackEventPayload')
â
Slack types accessible
# Protocol definitions (PEP 544)
assert hasattr(types, 'EventHandlerProtocol')
assert hasattr(types, 'QueueBackendProtocol')
â
Protocol types accessible
# Type guard functions
assert hasattr(types, 'is_slack_channel_id')
assert hasattr(types, 'is_slack_user_id')
assert hasattr(types, 'is_slack_timestamp')
â
Type guards accessible
Type Guard Functionality Testing
Validates runtime type validation functions work correctly:
# Channel ID validation
assert types.is_slack_channel_id('C1234567890') == True
assert types.is_slack_channel_id('#general') == True
assert types.is_slack_channel_id('invalid') == False
â
Channel ID type guard works
# User ID validation
assert types.is_slack_user_id('U1234567890') == True
assert types.is_slack_user_id('W1234567890') == True
assert types.is_slack_user_id('invalid') == False
â
User ID type guard works
# Timestamp validation
assert types.is_slack_timestamp('1234567890.123456') == True
assert types.is_slack_timestamp('invalid') == False
â
Timestamp type guard works