aws-samples / aws-samples/amazon-bedrock-flows-samples
TypeError: unsupported operand type(s) for |: Python 3.9 incompatibility in type annotations
- Dominant language
- Python
- Stars
- 100
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Running `bedrock_flow_manager.py` on Python < 3.10 raises a `TypeError` at import time due to use of the `X | Y` union type syntax introduced in Python 3.10.
## Error
Traceback (most recent call last):
File "src/bedrock_flow_manager.py", line 71, in
class BedrockFlowManager:
File "src/bedrock_flow_manager.py", line 731, in BedrockFlowManager
def test_flow(self, flow_id: str, alias_id: str, input_text: str | list, ...
TypeError: unsupported operand type(s) for |: 'type' and 'type'
## Reproducible Steps
1. Use Python 3.9 (e.g. default on Amazon Linux 2, macOS system Python)
2. Run `python src/bedrock_flow_manager.py --test-input "What is Amazon Bedrock?"`
## Environment
- Python version: 3.9.x
- Affected file: `src/bedrock_flow_manager.py` (lines 731, 845)
## Fix
Replace `str | list` and `str | dict` with `Union[str, list]` and `Union[str, dict]` from `typing`.
Contributor guide
Assessment
This issue has not been assessed yet.