This repository was archived by the owner on Aug 8, 2025. It is now read-only.
Fix crash when handling complex type hints in function signatures #161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!! This PR resolves an issue where Bowler would crash when transforming functions with complex type annotations like typing.List[str].
🐞Problem:
When processing code like:
"""
def foo(bar: typing.List[str]):
pass
"""
Bowler raised:
""" AttributeError: 'Node' object has no attribute 'value' """
✅My Solution for the above problem :
Updated FunctionArgument.build() to:
-Safely check whether the annotation is a Leaf or Node
-Use .value for Leaf, str(...) for complex Nodes
-Clone values safely and avoid AttributeError
🧪Tests Added
New test file: test_typehints.py
Verifies Query(...).add_argument(...) works correctly with functions using typehints like typing.List[str]
🔄Code Changes
In imr.py:
Improved logic in FunctionArgument.build() for safe annotation parsing
In query.py:
Added a lightweight inline test for typing.List[str]
In tests/test_typehints.py:
Full test case validating transformation on typehinted functions
🧵Related Issue
Closes #129