Skip to content

Commit

Permalink
feat: utilize almost majority of UP rules
Browse files Browse the repository at this point in the history
JIRA: TRIVIAL
risk: low
  • Loading branch information
hkad98 committed Aug 15, 2024
1 parent 73e61db commit d51ea62
Show file tree
Hide file tree
Showing 49 changed files with 84 additions and 86 deletions.
2 changes: 1 addition & 1 deletion gooddata-dbt/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def _read_json(path: Union[str, Path]) -> dict:
with open(path, "r") as f:
with open(path) as f:
return json.load(f)


Expand Down
5 changes: 1 addition & 4 deletions gooddata-fdw/gooddata_fdw/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# (C) 2021 GoodData Corporation
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore # mypy issue #1153
from importlib import metadata

__version__: str = metadata.version("gooddata-fdw")
3 changes: 2 additions & 1 deletion gooddata-fdw/gooddata_fdw/executor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# (C) 2022 GoodData Corporation
from __future__ import annotations

from typing import Any, Generator, NamedTuple, Optional
from collections.abc import Generator
from typing import Any, NamedTuple, Optional

from gooddata_sdk import GoodDataSdk

Expand Down
2 changes: 1 addition & 1 deletion gooddata-fdw/gooddata_fdw/fdw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class GoodDataForeignDataWrapper(ForeignDataWrapper):
def __init__(self, options: dict[str, str], columns: dict[str, ColumnDefinition]) -> None:
super(GoodDataForeignDataWrapper, self).__init__(options, columns)
super().__init__(options, columns)
_log_debug(f"initializing (options={options}, columns={columns})")

# Table options contain also foreign server options
Expand Down
3 changes: 2 additions & 1 deletion gooddata-fdw/gooddata_fdw/result_reader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# (C) 2022 GoodData Corporation
from __future__ import annotations

from typing import Any, Generator
from collections.abc import Generator
from typing import Any

from gooddata_sdk import ExecutionTable
from gooddata_sdk.type_converter import DBTypeConverterStore
Expand Down
2 changes: 1 addition & 1 deletion gooddata-fdw/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def pytest_addoption(parser):
@pytest.fixture(scope="session")
def test_config(request):
config_path = Path(request.config.getoption("--gd-test-config"))
with open(config_path, "rt") as f:
with open(config_path) as f:
config = yaml.safe_load(f)

return config
Expand Down
5 changes: 1 addition & 4 deletions gooddata-flight-server/gooddata_flight_server/_version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# (C) 2024 GoodData Corporation
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore # mypy issue #1153
from importlib import metadata

try:
__version__ = metadata.version("gooddata-flight-server")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# (C) 2024 GoodData Corporation
import importlib
from typing import Iterable
from collections.abc import Iterable

import structlog

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# (C) 2024 GoodData Corporation
from typing import Iterable, Optional, Union
from collections.abc import Iterable
from typing import Optional, Union

import pyarrow
import structlog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# (C) 2024 GoodData Corporation
from typing import Generator, Optional
from collections.abc import Generator
from typing import Optional

import orjson
import pyarrow.flight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- FlightServerMethods - base class containing typed definitions of all Flight RPC Methods
"""

from typing import Generator, Optional, Union
from collections.abc import Generator
from typing import Optional, Union

import pyarrow.flight
from typing_extensions import TypeAlias
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# (C) 2024 GoodData Corporation
from typing import Generator
from collections.abc import Generator

import pyarrow.flight

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# (C) 2024 GoodData Corporation
import abc
import threading
from collections.abc import Generator, Iterable
from dataclasses import dataclass
from typing import Generator, Iterable, Optional, Union, final
from typing import Optional, Union, final

import pyarrow.flight
from readerwriterlock import rwlock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# (C) 2024 GoodData Corporation
import threading
import time
from collections.abc import Iterator
from dataclasses import dataclass
from typing import Any, Callable, Generic, Iterator, Optional, TypeVar
from typing import Any, Callable, Generic, Optional, TypeVar

import structlog
from readerwriterlock import rwlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import abc
import threading
import time
from collections.abc import Generator
from concurrent.futures import CancelledError, Future, ThreadPoolExecutor
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Any, Generator, Optional, Union
from typing import Any, Optional, Union

import opentelemetry.context as otelctx
import pyarrow.flight
Expand Down
3 changes: 2 additions & 1 deletion gooddata-flight-server/tests/server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import contextlib
import os
import socket
from collections.abc import Iterable
from contextlib import closing
from pathlib import Path
from typing import Iterable, Union
from typing import Union

import pytest
from gooddata_flight_server.flexfun.flight_methods import (
Expand Down
2 changes: 1 addition & 1 deletion gooddata-flight-server/tests/server/test_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# (C) 2024 GoodData Corporation
import os
from typing import Generator
from collections.abc import Generator

import pyarrow.flight
import pytest
Expand Down
5 changes: 1 addition & 4 deletions gooddata-pandas/gooddata_pandas/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# (C) 2021 GoodData Corporation
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore # mypy issue #1153
from importlib import metadata

__version__: str = metadata.version("gooddata-pandas")
2 changes: 1 addition & 1 deletion gooddata-pandas/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _load_test_env():
test_env = find_dotenv(".env.test", raise_error_if_not_found=True)

return dotenv_values(test_env)
except IOError:
except OSError:
return dict()


Expand Down
2 changes: 1 addition & 1 deletion gooddata-pandas/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def pytest_addoption(parser):
@pytest.fixture(scope="session")
def test_config(request):
config_path = Path(request.config.getoption("--gd-test-config"))
with open(config_path, "rt") as f:
with open(config_path) as f:
config = yaml.safe_load(f)

return config
2 changes: 1 addition & 1 deletion gooddata-pandas/tests/good_pandas/test_good_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def load_profiles_content(path: Union[str, Path]) -> dict:
with open(path, "r", encoding="utf-8") as f:
with open(path, encoding="utf-8") as f:
return yaml.safe_load(f)


Expand Down
5 changes: 1 addition & 4 deletions gooddata-sdk/gooddata_sdk/_version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# (C) 2021 GoodData Corporation
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore # mypy issue #1153
from importlib import metadata

try:
__version__ = metadata.version("gooddata-sdk")
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/data_source/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CatalogDataSourceService(CatalogServiceBase):
"""

def __init__(self, api_client: GoodDataApiClient) -> None:
super(CatalogDataSourceService, self).__init__(api_client)
super().__init__(api_client)

# Entities methods are listed below

Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/export/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExportService(CatalogServiceBase):
"""

def __init__(self, api_client: GoodDataApiClient) -> None:
super(ExportService, self).__init__(api_client)
super().__init__(api_client)
"""
Initializes the ExportService with the GoodDataApiClient instance.
Args:
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/organization/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class CatalogOrganizationService(CatalogServiceBase):
def __init__(self, api_client: GoodDataApiClient) -> None:
super(CatalogOrganizationService, self).__init__(api_client)
super().__init__(api_client)

def update_oidc_parameters(
self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# (C) 2023 GoodData Corporation
from typing import Optional, Type
import builtins
from typing import Optional

import attr
from gooddata_api_client.model.dashboard_permissions import DashboardPermissions
Expand Down Expand Up @@ -50,7 +51,7 @@ class CatalogRulePermission(Base):
permissions: Optional[list[str]] = None

@staticmethod
def client_class() -> Type[RulePermission]: # noqa: UP006
def client_class() -> builtins.type[RulePermission]: # noqa: UP006
return RulePermission


Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/permission/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class CatalogPermissionService(CatalogServiceBase):
def __init__(self, api_client: GoodDataApiClient) -> None:
super(CatalogPermissionService, self).__init__(api_client)
super().__init__(api_client)

def get_declarative_permissions(self, workspace_id: str) -> CatalogDeclarativeWorkspacePermissions:
"""Retrieve current set of permissions of the workspace in a declarative form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CatalogWorkspaceContentService(CatalogServiceBase):
# access returned object's properties

def __init__(self, api_client: GoodDataApiClient) -> None:
super(CatalogWorkspaceContentService, self).__init__(api_client)
super().__init__(api_client)

# Entities methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def load_from_disk(cls, layout_organization_folder: Path) -> CatalogDeclarativeW
)
return cls(workspace_data_filters=workspace_data_filters)

def create_copy(
self, source_ws_id: str, target_ws_id: str
) -> tuple["CatalogDeclarativeWorkspaceDataFilters", dict]:
def create_copy(self, source_ws_id: str, target_ws_id: str) -> tuple[CatalogDeclarativeWorkspaceDataFilters, dict]:
self_copy = copy.deepcopy(self)
# update workspace data filter settings
for wdf in self_copy.workspace_data_filters:
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/workspace/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class CatalogWorkspaceService(CatalogServiceBase):
def __init__(self, api_client: GoodDataApiClient) -> None:
super(CatalogWorkspaceService, self).__init__(api_client)
super().__init__(api_client)
self._permissions_service = CatalogPermissionService(api_client)

# Entities methods
Expand Down
1 change: 0 additions & 1 deletion gooddata-sdk/gooddata_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from __future__ import annotations

from builtins import bytes
from typing import Optional

import gooddata_api_client as api_client
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/compute/model/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, local_id: str, label: Union[ObjId, str], show_all_values: Opt
label: identifier of the label to use for slicing or dicing; specified either as ObjId or str the label id
show_all_values: request show all values functionality for a given attribute
"""
super(Attribute, self).__init__()
super().__init__()

self._local_id = local_id
self._label = ObjId(label, "label") if isinstance(label, str) else label
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/compute/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def as_api_model(self) -> OpenApiModel:

class Filter(ExecModelEntity):
def __init__(self) -> None:
super(Filter, self).__init__()
super().__init__()

self._apply_on_result = None

Expand Down
14 changes: 7 additions & 7 deletions gooddata-sdk/gooddata_sdk/compute/model/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _to_identifier(val: Union[ObjId, str]) -> Union[afm_models.AfmLocalIdentifie

class AttributeFilter(Filter):
def __init__(self, label: Union[ObjId, str, Attribute], values: Optional[list[str]] = None) -> None:
super(AttributeFilter, self).__init__()
super().__init__()

self._label = _extract_id_or_local_id(label)
self._values = values or []
Expand Down Expand Up @@ -153,7 +153,7 @@ def description(self, labels: dict[str, str], format_locale: Optional[str] = Non

class RelativeDateFilter(Filter):
def __init__(self, dataset: ObjId, granularity: str, from_shift: int, to_shift: int) -> None:
super(RelativeDateFilter, self).__init__()
super().__init__()

if granularity not in _GRANULARITY:
raise ValueError(
Expand Down Expand Up @@ -248,7 +248,7 @@ class AllTimeFilter(Filter):
"""

def __init__(self, dataset: ObjId) -> None:
super(AllTimeFilter, self).__init__()
super().__init__()
self._dataset = dataset

@property
Expand All @@ -264,7 +264,7 @@ def description(self, labels: dict[str, str], format_locale: Optional[str] = Non

class AbsoluteDateFilter(Filter):
def __init__(self, dataset: ObjId, from_date: str, to_date: str) -> None:
super(AbsoluteDateFilter, self).__init__()
super().__init__()

self._dataset = dataset
self._from_date = from_date
Expand Down Expand Up @@ -334,7 +334,7 @@ def description(self, labels: dict[str, str], format_locale: Optional[str] = Non

class AllMetricValueFilter(Filter):
def __init__(self, metric: Union[ObjId, str, Metric]) -> None:
super(AllMetricValueFilter, self).__init__()
super().__init__()
self._metric = _extract_id_or_local_id(metric)

@property
Expand All @@ -357,7 +357,7 @@ def __init__(
values: Union[float, int, tuple[float, float]],
treat_nulls_as: Union[float, None] = None,
) -> None:
super(MetricValueFilter, self).__init__()
super().__init__()

if operator not in _METRIC_VALUE_FILTER_OPERATORS:
raise ValueError(
Expand Down Expand Up @@ -452,7 +452,7 @@ def __init__(
value: int,
dimensionality: Optional[list[Union[str, ObjId, Attribute, Metric]]],
) -> None:
super(RankingFilter, self).__init__()
super().__init__()

if operator not in _RANKING_OPERATORS:
raise ValueError(
Expand Down
Loading

1 comment on commit d51ea62

@GreatBahram
Copy link

Choose a reason for hiding this comment

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

👍

Please sign in to comment.