Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 7, 2026. It is now read-only.

Commit 6c9a18d

Browse filesBrowse files
authored
fix: simplify UnsupportedTypeError message (#2212)
* fix: simplify UnsupportedTypeError message * relax assertion
1 parent 2e2f119 commit 6c9a18d
Copy full SHA for 6c9a18d

3 files changed

+66-2Lines changed: 66 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bigframes/functions/function_typing.py‎

Copy file name to clipboardExpand all lines: bigframes/functions/function_typing.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,22 @@ class UnsupportedTypeError(ValueError):
6060
def __init__(self, type_, supported_types):
6161
self.type = type_
6262
self.supported_types = supported_types
63+
64+
types_to_format = supported_types
65+
if isinstance(supported_types, dict):
66+
types_to_format = supported_types.keys()
67+
68+
supported_types_str = ", ".join(
69+
sorted(
70+
[
71+
getattr(supported, "__name__", supported)
72+
for supported in types_to_format
73+
]
74+
)
75+
)
76+
6377
super().__init__(
64-
f"'{type_}' must be one of the supported types ({supported_types}) "
78+
f"'{getattr(type_, '__name__', type_)}' must be one of the supported types ({supported_types_str}) "
6579
"or a list of one of those types."
6680
)
6781

Collapse file

‎tests/system/small/functions/test_remote_function.py‎

Copy file name to clipboardExpand all lines: tests/system/small/functions/test_remote_function.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ def func_tuple(x):
16461646

16471647
with pytest.raises(
16481648
ValueError,
1649-
match=r"'typing\.Sequence\[int\]' must be one of the supported types",
1649+
match=r"must be one of the supported types",
16501650
):
16511651
bff.remote_function(
16521652
input_types=int,
Collapse file
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import datetime
16+
import decimal
17+
18+
import pytest
19+
20+
from bigframes.functions import function_typing
21+
22+
23+
def test_unsupported_type_error_init_with_dict():
24+
err = function_typing.UnsupportedTypeError(
25+
decimal.Decimal, {int: "INT64", float: "FLOAT64"}
26+
)
27+
28+
message = str(err)
29+
30+
assert "Decimal" in message
31+
assert "float, int" in message
32+
33+
34+
def test_unsupported_type_error_init_with_set():
35+
err = function_typing.UnsupportedTypeError(decimal.Decimal, {int, float})
36+
37+
message = str(err)
38+
39+
assert "Decimal" in message
40+
assert "float, int" in message
41+
42+
43+
def test_sdk_type_from_python_type_raises_unsupported_type_error():
44+
with pytest.raises(function_typing.UnsupportedTypeError) as excinfo:
45+
function_typing.sdk_type_from_python_type(datetime.datetime)
46+
47+
message = str(excinfo.value)
48+
49+
assert "datetime" in message
50+
assert "bool, bytes, float, int, str" in message

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.