Skip to content
Merged
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
5 changes: 3 additions & 2 deletions packages/gooddata-pandas/src/gooddata_pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import warnings
from typing import Callable, Union
from typing import Callable, Union, cast

import pandas
from gooddata_sdk import Attribute, Execution, Filter, GoodDataSdk, ObjId, SimpleMetric
Expand Down Expand Up @@ -156,7 +156,8 @@ def not_indexed(
stacklevel=2,
)
if isinstance(granularity, list):
_index: IndexDef | None = {str(idx): label for idx, label in enumerate(granularity)}
granularity_items = cast("list[LabelItemDef]", granularity)
_index: IndexDef | None = {str(idx): label for idx, label in enumerate(granularity_items)}
else:
_index = granularity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
"""

from enum import Enum
from typing import Any, Protocol
from typing import Any, Protocol, TypeVar

_T = TypeVar("_T")


class SingletonMeta(type):
_instances: dict = {}
_instances: dict[type, Any] = {}

def __call__(cls, *args: Any, **kwargs: Any) -> "SingletonMeta":
if cls not in cls._instances:
instance = super().__call__(*args, **kwargs)
cls._instances[cls] = instance
return cls._instances[cls]
def __call__(cls: type[_T], *args: Any, **kwargs: Any) -> _T:
if cls not in SingletonMeta._instances:
SingletonMeta._instances[cls] = type.__call__(cls, *args, **kwargs)
return SingletonMeta._instances[cls]


class Severity(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ def primary_label(self) -> Union[CatalogLabel, None]:

def find_label(self, id_obj: IdObjType) -> Union[CatalogLabel, None]:
obj_key = id_obj_to_key(id_obj)
# use cast as mypy is not applying next, it claims, type is filter[CatalogLabel]
return cast(
Union[CatalogLabel, None], next(filter(lambda x: id_obj_to_key(x.obj_id) == obj_key, self.labels), None)
)
return next(filter(lambda x: id_obj_to_key(x.obj_id) == obj_key, self.labels), None)

# TODO add missing properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def __init__(
self._from_shift = from_shift
self._to_shift = to_shift
self._bounded_filter = bounded_filter
self._empty_value_handling = empty_value_handling
self._empty_value_handling: EmptyValueHandling | None = empty_value_handling

@property
def dataset(self) -> ObjId:
Expand Down Expand Up @@ -435,7 +435,7 @@ def __init__(

self._dataset = dataset
self._granularity = granularity
self._empty_value_handling = empty_value_handling
self._empty_value_handling: EmptyValueHandling | None = empty_value_handling

@property
def dataset(self) -> ObjId:
Expand Down Expand Up @@ -490,7 +490,7 @@ def __init__(
self._dataset = dataset
self._from_date = from_date
self._to_date = to_date
self._empty_value_handling = empty_value_handling
self._empty_value_handling: EmptyValueHandling | None = empty_value_handling

@property
def dataset(self) -> ObjId:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ dev = [
"gitlint~=0.19.1",
]
lint = [
"ruff~=0.15.1",
"ruff~=0.15.15",
]
type = [
"ty~=0.0.14",
"ty~=0.0.40",
]
test = [
# Common test dependencies used across all workspace packages
Expand Down
Loading
Loading