Skip to content

Commit

Permalink
overload data_set/create for better type safety (#1402)
Browse files Browse the repository at this point in the history
Co-authored-by: Ola Liabøtrø <[email protected]>
  • Loading branch information
olacognite and Ola Liabøtrø authored Oct 3, 2023
1 parent 4512da3 commit 96d99c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [6.28.4] - 2023-10-03
### Fixed
- Overload data_set/create for improved type safety

## [6.28.3] - 2023-10-03
### Fixed
- When uploading files as strings using `client.files.upload_bytes` the wrong encoding is used on Windows, which is causing
Expand Down
10 changes: 9 additions & 1 deletion cognite/client/_api/data_sets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Iterator, Sequence, cast
from typing import TYPE_CHECKING, Any, Iterator, Sequence, cast, overload

from cognite.client._api_client import APIClient
from cognite.client._constants import DEFAULT_LIMIT_READ
Expand Down Expand Up @@ -73,6 +73,14 @@ def __iter__(self) -> Iterator[DataSet]:
"""
return cast(Iterator[DataSet], self())

@overload
def create(self, data_set: Sequence[DataSet]) -> DataSetList:
...

@overload
def create(self, data_set: DataSet) -> DataSet:
...

def create(self, data_set: DataSet | Sequence[DataSet]) -> DataSet | DataSetList:
"""`Create one or more data sets. <https://developer.cognite.com/api#tag/Data-sets/operation/createDataSets>`_
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "6.28.3"
__version__ = "6.28.4"
__api_subversion__ = "V20220125"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "6.28.3"
version = "6.28.4"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down

0 comments on commit 96d99c5

Please sign in to comment.