TypeError: unsupported operand type(s) for |: Python 3.9 incompatibility in type annotations
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Open src/bedrock_flow_manager.py and inspect the annotations at lines 731 and 845, then check how typing imports are organized. Run the documented Python 3.9 command with the sample input; done means the module imports and the command no longer raises this TypeError.
Written by the indexing model from the issue text.
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
- Use Python 3.9 (e.g. default on Amazon Linux 2, macOS system Python)
- 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.
- Dominant language
- Python
- Stars
- 100
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100