Skip to content

Commit 016505a

Browse files
committed
TMP
1 parent 8923004 commit 016505a

File tree

34 files changed

+612
-499
lines changed

34 files changed

+612
-499
lines changed

cognite/client/_basic_api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ def _init_async_http_clients(self) -> None:
199199
refresh_auth_header=self._refresh_auth_header,
200200
)
201201

202-
def __getstate__(self):
202+
def __getstate__(self) -> dict[str, Any]:
203203
"""Prepare object for pickling by removing unpicklable async clients."""
204204
state = self.__dict__.copy()
205205
state.pop("_http_client")
206206
state.pop("_http_client_with_retry")
207207
return state
208208

209-
def __setstate__(self, state):
209+
def __setstate__(self, state: dict[str, Any]) -> None:
210210
"""Restore object after unpickling."""
211211
self.__dict__.update(state)
212212
self._init_async_http_clients()

cognite/client/_constants.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
from typing import Literal
44

5+
__all__ = [
6+
"DATA_MODELING_DEFAULT_LIMIT_READ",
7+
"DEFAULT_DATAPOINTS_CHUNK_SIZE",
8+
"DEFAULT_LIMIT_READ",
9+
"MAX_VALID_INTERNAL_ID",
10+
"NUMPY_IS_AVAILABLE",
11+
"OMITTED",
12+
"_RUNNING_IN_BROWSER",
13+
]
14+
515
try:
616
from pyodide.ffi import IN_BROWSER as _RUNNING_IN_BROWSER # type: ignore [import-not-found]
717
except ModuleNotFoundError:

cognite/client/_sync_api/postgres_gateway/tables.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def retrieve(
120120
"""
121121
return run_sync(
122122
self.__async_client.postgres_gateway.tables.retrieve(
123-
username=username, tablename=tablename, ignore_unknown_ids=ignore_unknown_ids
123+
username=username,
124+
tablename=tablename,
125+
ignore_unknown_ids=ignore_unknown_ids, # type: ignore[arg-type]
124126
)
125127
)
126128

cognite/client/data_classes/datapoints.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,3 +1411,21 @@ def to_pandas( # type: ignore [override]
14111411
include_status=include_status,
14121412
include_unit=include_unit,
14131413
)
1414+
1415+
1416+
__all__ = [
1417+
"ALL_SORTED_DP_AGGS",
1418+
"Datapoint",
1419+
"DatapointList",
1420+
"DatapointsQuery",
1421+
"DatapointsQueryResult",
1422+
"DatapointsQueryResultList",
1423+
"MaxDatapoint",
1424+
"MaxDatapointWithStatus",
1425+
"MinDatapoint",
1426+
"MinDatapointWithStatus",
1427+
"NumericDatapoint",
1428+
"NumericDatapointList",
1429+
"StringDatapoint",
1430+
"StringDatapointList",
1431+
]

cognite/client/data_classes/files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ async def __aexit__(
613613
self._check_errors_before_completing(exc_type)
614614
await self._cognite_client.files._complete_multipart_upload(self)
615615
self._upload_is_finalized = True
616+
return None
616617

617618
def __enter__(self) -> Self:
618619
if self._upload_is_finalized:
@@ -621,9 +622,9 @@ def __enter__(self) -> Self:
621622

622623
def __exit__(
623624
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
624-
) -> bool | None:
625+
) -> None:
625626
if exc_type is not None:
626-
return False
627+
return
627628

628629
self._check_errors_before_completing(exc_type)
629630
run_sync(self._cognite_client.files._complete_multipart_upload(self))

cognite/client/data_classes/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ def __init__(
13891389
) -> None:
13901390
super().__init__(with_, select)
13911391
# Parameters and cursors are not supported for workflow trigger queries:
1392-
self.parameters = None
1392+
self.parameters = None # type: ignore [assignment]
13931393
self.cursors = None # type: ignore [assignment]
13941394

13951395
@classmethod

cognite/client/utils/_pandas_helpers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from cognite.client.utils._time import TIME_ATTRIBUTES
2626

2727
if TYPE_CHECKING:
28+
import numpy as np
29+
import numpy.typing as npt
2830
import pandas as pd
2931

3032
from cognite.client.data_classes import Datapoints, DatapointsArray, DatapointsArrayList, DatapointsList
@@ -200,7 +202,7 @@ def convert_dps_to_dataframe(
200202
include_status: bool,
201203
include_unit: bool,
202204
include_errors: bool = False, # old leftover misuse of Datapoints class :(
203-
):
205+
) -> pd.DataFrame:
204206
pd = local_import("pandas")
205207
columns = _extract_column_info_from_dps_for_dataframe(
206208
dps, include_status=include_status, include_errors=include_errors
@@ -262,7 +264,7 @@ def as_array(self) -> NumpyObjArray | NumpyFloat64Array | NumpyInt64Array | Nump
262264
else:
263265
return self._convert_to_array_for_agg_dps()
264266

265-
def _convert_to_array_for_raw_dps(self):
267+
def _convert_to_array_for_raw_dps(self) -> npt.NDArray[np.object_]:
266268
import numpy as np
267269

268270
match self.is_string, self.status_info:
@@ -279,7 +281,7 @@ def _convert_to_array_for_raw_dps(self):
279281
# the datapoints object themselves:
280282
assert_never(f"Invalid combination of is_string={self.is_string} and status_info={self.status_info}")
281283

282-
def _convert_to_array_for_agg_dps(self):
284+
def _convert_to_array_for_agg_dps(self) -> npt.NDArray[np.object_]:
283285
import numpy as np
284286

285287
from cognite.client.utils._datapoints import ensure_int_numpy

cognite/client/utils/_time.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,20 @@ def split_time_range(start: int, end: int, n_splits: int, granularity_in_ms: int
346346
# Find a `delta_ms` that's a multiple of granularity in ms (trivial for raw queries).
347347
delta_ms = granularity_in_ms * round(tot_ms / n_splits / granularity_in_ms)
348348
return [*(start + delta_ms * i for i in range(n_splits)), end]
349+
350+
351+
__all__ = [
352+
"MAX_TIMESTAMP_MS",
353+
"MIN_TIMESTAMP_MS",
354+
"ZoneInfo",
355+
"convert_and_isoformat_time_attrs",
356+
"convert_data_modeling_timestamp",
357+
"datetime_to_ms",
358+
"datetime_to_ms_iso_timestamp",
359+
"granularity_to_ms",
360+
"ms_to_datetime",
361+
"parse_str_timezone",
362+
"parse_str_timezone_offset",
363+
"split_time_range",
364+
"timestamp_to_ms",
365+
]

0 commit comments

Comments
 (0)