Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/openai/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ def wrapper(*args: object, **kwargs: object) -> object:
else:
assert len(variants) > 0

# TODO: this error message is not deterministic
missing = list(set(variants[0]) - given_params)
missing = [param for param in variants[0] if param not in given_params]
if len(missing) > 1:
msg = f"Missing required arguments: {human_join([quote(arg) for arg in missing])}"
else:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_required_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def foo(a: str = "", *, b: str = "", c: str = "") -> str | None:

assert foo(a="a", b="b", c="c") == "a b c"

error_message = r"Missing required arguments.*"

with pytest.raises(TypeError, match=error_message):
with pytest.raises(TypeError) as exc_info:
foo()
assert str(exc_info.value) == "Missing required arguments: 'a', 'b' or 'c'"

error_message = r"Missing required arguments.*"

with pytest.raises(TypeError, match=error_message):
foo(a="a")
Expand Down