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: 2 additions & 1 deletion src/cohere/core/unchecked_base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ def construct_type(
if not isinstance(object_, typing.Mapping):
return object_

key_type, items_type = get_args(type_)
args = get_args(type_)
key_type, items_type = args if args else (typing.Any, typing.Any)
key_type = _maybe_resolve_forward_ref(key_type, host)
items_type = _maybe_resolve_forward_ref(items_type, host)
d = {
Expand Down
11 changes: 11 additions & 0 deletions tests/test_unchecked_base_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary sys.path hack inconsistent with other tests

Low Severity

The sys.path.insert hack is inconsistent with every other test file in this project, which all import cohere directly without path manipulation. The project uses pyproject.toml with packages = [{ include = "cohere", from = "src"}] and expects the package to be installed in the environment (via poetry install or equivalent). This workaround bypasses that and could cause subtle import-ordering issues if the installed package and source tree ever diverge.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e6db0dd. Configure here.


from cohere.core.unchecked_base_model import construct_type


def test_construct_type_bare_dict_no_unpack_error():
# bare dict (unparameterized) must not raise ValueError on get_args unpacking
result = construct_type(type_=dict, object_={"key": "value"})
assert result == {"key": "value"}