A CLI tool that generates Python Enum classes from Serverless Framework configuration files. This tool parses your serverless.yml file and creates type-safe Enum objects for Lambda function names, making it easier to reference your functions in Python code.
- Generate Python Enum classes from
serverless.ymlfiles - Support for stage-specific function naming
- Type-safe Lambda function name references
- Dry-run mode for previewing generated code
- Easy integration with existing Python projects
pip install sls_enumOr using Poetry:
poetry add sls_enumGenerate an Enum class from your serverless.yml:
sls_enum serverless.yml output.pyInclude stage in function names:
sls_enum serverless.yml output.py --stage devPreview the generated code without writing to file:
sls_enum serverless.yml output.py --dry-runGiven a serverless.yml with functions like:
service: my-service
functions:
sample-handler:
handler: handler.sample
another-handler:
handler: handler.anotherThe tool generates:
from enum import Enum
class LambdaHandlers(str, Enum):
sample_handler = "my-service-sample-handler"
another_handler = "my-service-another-handler"FP: Path to serverless.yml file (required)OUTPUT: Output Python file path (required)--stage TEXT: Stage name to include in function names--dry-run: Preview generated code without writing to file--help: Show help message
poetry installpoetry run pytestpoetry run black .
poetry run isort .Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run tests and ensure code formatting
- Create a pull request targeting the main branch
- Assign @hayata-yamamoto as a reviewer
See LICENSE file for details.