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
4 changes: 2 additions & 2 deletions cognite/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class ClientConfig:
cluster (str | None): The cluster where the CDF project is located. When passed, it is assumed that the base
URL can be constructed as: ``https://<cluster>.cognitedata.com``. Either base_url or cluster must be provided.
headers (dict[str, str] | None): Additional headers to add to all requests.
timeout (int | None): Timeout on requests sent to the api. Defaults to 60 seconds.
timeout (float | None): Timeout on requests sent to the api. Defaults to 60 seconds.
file_transfer_timeout (int | None): Timeout on file upload/download requests. Defaults to 600 seconds.
debug (bool): Enables debug logging to stderr. This includes full request/response details and logs regarding retry
attempts (e.g., on 429 throttling or 5xx errors).
Expand All @@ -205,7 +205,7 @@ def __init__(
base_url: str | None = None,
cluster: str | None = None,
headers: dict[str, str] | None = None,
timeout: int | None = None,
timeout: float | None = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While updating the type hint of timeout to float | None, please note that the current implementation in __init__ uses self.timeout = timeout or 60. Since 0.0 is a falsy value in Python, passing timeout=0.0 (which is a valid float timeout for non-blocking/immediate timeout) will be incorrectly overridden to 60.\n\nTo fix this correctness issue, the assignment should be updated to:\npython\nself.timeout = 60 if timeout is None else timeout\n\n\nAdditionally, for consistency and completeness, file_transfer_timeout should also be updated to support float | None instead of strictly int | None.

References
  1. Strong Typing: Use type hints extensively with MyPy. Avoid Any when possible (link)

file_transfer_timeout: int | None = None,
debug: bool = False,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/tests_integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def make_cognite_client() -> CogniteClient:
project=os.environ["COGNITE_PROJECT"],
base_url=os.environ["COGNITE_BASE_URL"],
credentials=credentials,
timeout=59.9, # Test that a non-int timeout works

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Relying on the global integration test client configuration to verify that float timeouts work is not a robust testing strategy. It doesn't explicitly assert the behavior and could be easily lost or modified in the future.\n\nPlease add a dedicated unit test (e.g., in tests/tests_unit/test_config.py) that instantiates ClientConfig with a float timeout and asserts that client.config.timeout is correctly set to the float value. This ensures explicit test coverage and prevents regressions.

)
)

Expand Down
Loading