Bowler icon indicating copy to clipboard operation
Bowler copied to clipboard

Fix crash when handling complex type hints in function signatures

Open praharsh777 opened this issue 8 months ago • 4 comments

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

praharsh777 avatar Apr 04 '25 09:04 praharsh777

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!

facebook-github-bot avatar Apr 04 '25 09:04 facebook-github-bot

Hi, I've signed the CLA. Just waiting for the status to update. Thanks!

praharsh777 avatar Apr 04 '25 09:04 praharsh777

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Apr 04 '25 10:04 facebook-github-bot

Hi @facebook-github-bot , just checking in to see if this PR needs any changes. Happy to help!

praharsh777 avatar Apr 04 '25 10:04 praharsh777