Skip to content

Commit

Permalink
Upgrade mypy to ^1 (#1363)
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonvt authored Sep 15, 2023
1 parent 79a655f commit b1cdf81
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 165 deletions.
8 changes: 4 additions & 4 deletions cognite/client/_api/datapoint_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
from cognite.client._proto.data_point_list_response_pb2 import DataPointListItem
from cognite.client._proto.data_points_pb2 import AggregateDatapoint, NumericDatapoint, StringDatapoint
else:
from cognite.client._proto_legacy.data_point_list_response_pb2 import DataPointListItem # type: ignore [misc]
from cognite.client._proto_legacy.data_points_pb2 import ( # type: ignore [misc]
from cognite.client._proto_legacy.data_point_list_response_pb2 import DataPointListItem # type: ignore [assignment]
from cognite.client._proto_legacy.data_points_pb2 import ( # type: ignore [assignment]
AggregateDatapoint,
NumericDatapoint,
StringDatapoint,
Expand Down Expand Up @@ -624,7 +624,7 @@ def get_next_payload(self) -> CustomDatapoints | None:
def _create_payload_item(self) -> CustomDatapoints:
return CustomDatapoints(
{
**self.identifier.as_dict(), # type: ignore [misc]
**self.identifier.as_dict(), # type: ignore [typeddict-item]
"start": self.start,
"end": self.end,
"limit": 0, # Not a bug; it just returns the outside points
Expand Down Expand Up @@ -685,7 +685,7 @@ def get_next_payload(self) -> CustomDatapoints | None:
def _create_payload_item(self, remaining_limit: float) -> CustomDatapoints:
return CustomDatapoints(
{
**self.identifier.as_dict(), # type: ignore [misc]
**self.identifier.as_dict(), # type: ignore [typeddict-item]
"start": self.next_start,
"end": self.end,
"limit": min(remaining_limit, self.max_query_limit),
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_api/datapoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
if not import_legacy_protobuf():
from cognite.client._proto.data_point_list_response_pb2 import DataPointListItem, DataPointListResponse
else:
from cognite.client._proto_legacy.data_point_list_response_pb2 import ( # type: ignore [misc]
from cognite.client._proto_legacy.data_point_list_response_pb2 import ( # type: ignore [assignment]
DataPointListItem,
DataPointListResponse,
)
Expand Down
7 changes: 5 additions & 2 deletions cognite/client/_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import socket
import time
from http import cookiejar
from typing import Any, Callable, MutableMapping
from typing import Any, Callable, Literal, MutableMapping

import requests
import requests.adapters
Expand All @@ -16,7 +16,10 @@


class BlockAll(cookiejar.CookiePolicy):
return_ok = set_ok = domain_return_ok = path_return_ok = lambda self, *args, **kwargs: False
def no(*args: Any, **kwargs: Any) -> Literal[False]:
return False

return_ok = set_ok = domain_return_ok = path_return_ok = no
netscape = True
rfc2965 = hide_cookie2 = False

Expand Down
4 changes: 0 additions & 4 deletions cognite/client/data_classes/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ class AggregationFilter(ABC):
def dump(self) -> dict[str, Any]:
return {self._filter_name: self._filter_body()}

@classmethod
def load(cls, filter_: dict[str, Any]) -> AggregationFilter:
...

@abstractmethod
def _filter_body(self) -> list | dict:
raise NotImplementedError
Expand Down
5 changes: 3 additions & 2 deletions cognite/client/data_classes/data_modeling/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC
from dataclasses import asdict, dataclass
from typing import ClassVar
from typing import Any, ClassVar

from cognite.client.data_classes.data_modeling.ids import ContainerId
from cognite.client.utils._auxiliary import rename_and_exclude_keys
Expand Down Expand Up @@ -35,10 +35,11 @@ def as_tuple(self) -> tuple[str, str]:
return self.space, self.external_id


@dataclass
class PropertyType(ABC):
_type: ClassVar[str]

def dump(self, camel_case: bool = False) -> dict:
def dump(self, camel_case: bool = False) -> dict[str, Any]:
output = asdict(self)
output["type"] = self._type
output = rename_and_exclude_keys(output, aliases=_PROPERTY_ALIAS_INV)
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/data_classes/data_modeling/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def external_id(self) -> str:
...


class VersionedIdLike(IdLike):
class VersionedIdLike(IdLike, Protocol):
@property
def version(self) -> str | None:
...
Expand Down
299 changes: 149 additions & 150 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pre-commit = "^2.20.0"
responses = "^0.21.0"
toml = "^0.10.2"
python-dotenv = "^0.20.0"
mypy = "^0.981"
mypy = "^1"
types-urllib3 = "^1.26.16"
types-requests = "^2.28.1"
pep8-naming = "^0"
Expand Down

0 comments on commit b1cdf81

Please sign in to comment.