-
Notifications
You must be signed in to change notification settings - Fork 63
feat: improve UnsupportedTypeError message
#2203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The `UnsupportedTypeError` now provides a more user-friendly error message by displaying a sorted, comma-separated list of supported type names instead of the raw object representations. This improves clarity and makes it easier for developers to identify the correct types to use. Added a new test file, `tests/unit/functions/test_function_typing.py`, with unit tests to ensure the error message is formatted correctly for different types of collections (dictionaries and sets) and that the exception is raised with the expected message.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. |
UnsupportedTypeError Message and Add TestsUnsupportedTypeError message
| err = function_typing.UnsupportedTypeError( | ||
| decimal.Decimal, {int: "INT64", float: "FLOAT64"} | ||
| ) | ||
| assert "Decimal" in str(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: insert empty lines between "arrange" "act" "assert" blocks: go/unit-testing-practices?polyglot=python#structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@google-labs-jules please address this nit: insert empty lines between "arrange" "act" "assert" blocks: go/unit-testing-practices?polyglot=python#structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've restructured the tests to improve readability.
|
@google-labs-jules This test failure looks like a real one. Please fix. |
You were right, that was a real test failure. I've pushed a fix that should resolve the |
This commit fixes a test failure caused by an `AttributeError` when handling generic types from the `typing` module in the `UnsupportedTypeError` class. The `__init__` method of `UnsupportedTypeError` has been updated to check if a type is a generic from the `typing` module and, if so, convert it to a string directly to get the full type representation (e.g., `list[str]`). This ensures that the error message is generated correctly without raising an `AttributeError`. A new unit test has also been added to `tests/unit/functions/test_function_typing.py` to verify the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Another bad merge. I'll try to get Jules to sync to main again.
This commit fixes a test failure caused by an `AttributeError` when handling generic types from the `typing` module in the `UnsupportedTypeError` class. The `__init__` method of `UnsupportedTypeError` has been updated to check if a type is a generic from the `typing` module and, if so, convert it to a string directly to get the full type representation (e.g., `list[str]`). This ensures that the error message is generated correctly without raising an `AttributeError`. A new unit test has also been added to `tests/unit/functions/test_function_typing.py` to verify the fix.
|
I give up on Jules. I'll try to fix myself. |
Pull request was closed
This change addresses an issue where the
UnsupportedTypeErrorexception produced a messy and unhelpful error message. The original implementation displayed the raw representation of the supported types, including memory addresses, which was not useful for debugging. This commit refactors the exception to output a clean, sorted list of supported type names, making it easier for users to understand and correct their code. Additionally, new unit tests have been added to verify the new error message format and ensure the exception is raised correctly.PR created automatically by Jules for task 17087358634619041143