Fix crash when handling complex type hints in function signatures
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
Hi @praharsh777!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
Hi, I've signed the CLA. Just waiting for the status to update. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
Hi @facebook-github-bot , just checking in to see if this PR needs any changes. Happy to help!