Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/gooddata-dbt/src/gooddata_dbt/dbt_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def create_localized_workspaces(
if data_product.localization is None:
return
try:
from deep_translator import GoogleTranslator
from deep_translator import GoogleTranslator # noqa: PLC0415
except ImportError:
logger.warning(
"create_localized_workspaces: deep_translator module not found, will not be able to localize workspaces"
Expand Down
2 changes: 1 addition & 1 deletion packages/gooddata-dbt/src/gooddata_dbt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def report_message_to_merge_request(token: str, merge_request_id: str, text: str

def report_message_to_pull_request(logger: Logger, token: str, pull_request_id: int, text: str) -> None:
try:
from github import Auth, Github
from github import Auth, Github # noqa: PLC0415

auth = Auth.Token(token)
g = Github(auth=auth)
Expand Down
3 changes: 1 addition & 2 deletions packages/gooddata-fdw/src/gooddata_fdw/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
# package-specific global variable would inevitably lead to evaluation of __init__ which imports the FDW code
# which will then try to import from this file before the variable is even set
import sys
from logging import getLevelName

if "pytest" not in sys.modules and "sphinx" not in sys.modules:
# multicorn stuff cannot be imported & the FDW code is not currently under test or as documentation build.
# in that case raise the error normally.
raise e

def _log_to_console(msg: str, level: int) -> None:
from logging import getLevelName

print(f"{getLevelName(level)}: {msg}")

log_to_postgres = _log_to_console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ def _create_console_span_exporter() -> SpanExporter:


def _create_zipkin_span_exporter() -> SpanExporter:
from opentelemetry.exporter.zipkin.json import (
from opentelemetry.exporter.zipkin.json import ( # noqa: PLC0415
ZipkinExporter,
)

return ZipkinExporter()


def _create_otlp_grpc_exporter() -> SpanExporter:
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import ( # noqa: PLC0415
OTLPSpanExporter,
)

return OTLPSpanExporter()


def _create_otlp_http_exporter() -> SpanExporter:
from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( # noqa: PLC0415
OTLPSpanExporter,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Module for managing workspace data filter settings in GoodData Cloud."""

import json
import os
from typing import Any
from uuid import uuid4

Expand Down Expand Up @@ -40,8 +41,6 @@ def _create_wdf_setting_dict(
"""Loads a JSON template of a WDF setting and fills it with the given values."""
values = [str(value) for value in wdf_values]

import os

wdf_setting_path = os.path.join(
os.path.dirname(__file__), "../../assets/wdf_setting.json"
)
Expand Down
3 changes: 1 addition & 2 deletions packages/gooddata-sdk/src/gooddata_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from __future__ import annotations

import os
from pathlib import Path

import gooddata_api_client as api_client
Expand Down Expand Up @@ -59,8 +60,6 @@ def __init__(
)

if proxy is None:
import os

proxy = (
os.environ.get("HTTPS_PROXY")
or os.environ.get("https_proxy")
Expand Down
19 changes: 5 additions & 14 deletions packages/gooddata-sdk/tests/catalog/test_aac.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# (C) 2026 GoodData Corporation
from __future__ import annotations

import shutil
import tempfile
from pathlib import Path

import yaml
Expand All @@ -16,6 +18,9 @@
load_aac_workspace_from_disk,
store_aac_workspace_to_disk,
)
from gooddata_sdk.catalog.workspace.declarative_model.workspace.workspace import (
CatalogDeclarativeWorkspaceModel,
)
from gooddata_sdk.config import AacConfig

_FIXTURES_DIR = Path(__file__).parent / "unit_tests" / "aac_tests"
Expand Down Expand Up @@ -243,9 +248,6 @@ class TestWorkspaceLoadStore:
def test_load_aac_workspace_from_fixtures(self) -> None:
"""Load fixtures excluding dashboards (WASM crypto limitation)."""
# Use a temp dir with only datasets, metrics, visualizations
import shutil
import tempfile

with tempfile.TemporaryDirectory() as tmp:
tmp_path = Path(tmp)
for subdir in ("datasets", "metrics", "visualisations"):
Expand Down Expand Up @@ -280,10 +282,6 @@ def test_store_and_reload_metrics(self, tmp_path: Path) -> None:
metrics_declarative = [aac_metric_to_declarative(m) for m in aac_metrics]

model_dict = {"analytics": {"metrics": metrics_declarative}}
from gooddata_sdk.catalog.workspace.declarative_model.workspace.workspace import (
CatalogDeclarativeWorkspaceModel,
)

model = CatalogDeclarativeWorkspaceModel.from_dict(model_dict)
store_aac_workspace_to_disk(model, tmp_path)

Expand Down Expand Up @@ -316,10 +314,6 @@ def test_store_and_reload_visualizations(self, tmp_path: Path) -> None:
vis_declarative = [aac_visualization_to_declarative(aac_vis)]

model_dict = {"analytics": {"visualizationObjects": vis_declarative}}
from gooddata_sdk.catalog.workspace.declarative_model.workspace.workspace import (
CatalogDeclarativeWorkspaceModel,
)

model = CatalogDeclarativeWorkspaceModel.from_dict(model_dict)
store_aac_workspace_to_disk(model, tmp_path)

Expand All @@ -334,9 +328,6 @@ def test_store_and_reload_visualizations(self, tmp_path: Path) -> None:

def test_store_and_reload_from_fixtures(self, tmp_path: Path) -> None:
"""Load fixtures, store to disk, reload — full round-trip."""
import shutil
import tempfile

with tempfile.TemporaryDirectory() as tmp:
fixture_path = Path(tmp)
for subdir in ("datasets", "metrics", "visualisations"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
GoodDataApiClient,
GoodDataSdk,
)
from gooddata_sdk.catalog.permission.declarative_model.permission import CatalogDeclarativeWorkspacePermissions
from gooddata_sdk.utils import recreate_directory
from tests_support.file_utils import load_json
from tests_support.vcrpy_utils import get_vcr

from .conftest import safe_delete
from .conftest import load_expected_data_sources, safe_delete

gd_vcr = get_vcr()

Expand Down Expand Up @@ -194,17 +195,13 @@ def _restore_demo2_permissions(sdk: GoodDataSdk, test_config: dict) -> None:
Note: This function makes HTTP calls. When used in tests with VCR cassettes,
ensure the cassette includes the restoration calls (in finally blocks).
"""
from .conftest import load_expected_data_sources

# Restore data source permissions
expected_ds_path = _current_dir / "expected" / "declarative_data_sources.json"
credentials_path = _current_dir / "load" / "data_source_credentials" / "data_sources_credentials.yaml"
data_sources = load_expected_data_sources(expected_ds_path, test_config)
sdk.catalog_data_source.put_declarative_data_sources(data_sources, credentials_path)

# Restore workspace permissions
from gooddata_sdk.catalog.permission.declarative_model.permission import CatalogDeclarativeWorkspacePermissions

expected_ws_path = _current_dir / "expected" / "declarative_workspace_permissions.json"
ws_data = load_json(expected_ws_path)
ws_permissions = CatalogDeclarativeWorkspacePermissions.from_dict(ws_data, camel_case=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from __future__ import annotations

import copy
from unittest.mock import MagicMock

from gooddata_sdk.catalog.workspace.service import CatalogWorkspaceService
Expand Down Expand Up @@ -309,7 +310,6 @@ def _service(self):

def test_translates_tab_titles(self):
"""Tab titles are translated."""
import copy

content = {
"tabs": [
Expand Down Expand Up @@ -349,7 +349,6 @@ def test_translates_tab_titles(self):

def test_translates_widgets_in_tabs(self):
"""Widget titles/descriptions inside tabs are translated."""
import copy

content = {
"tabs": [
Expand Down Expand Up @@ -392,7 +391,6 @@ def test_translates_widgets_in_tabs(self):

def test_legacy_layout_still_works(self):
"""Legacy layout dashboards still get their widgets translated."""
import copy

content = {
"layout": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

pyarrow = pytest.importorskip("pyarrow")

import pyarrow as pa # noqa: E402
from gooddata_sdk.compute.model import execution as _exec_mod # noqa: E402
from gooddata_sdk.compute.model.execution import BareExecutionResponse # noqa: E402
from pyarrow import ipc # noqa: E402


def _make_ipc_stream_bytes() -> bytes:
"""Return minimal Arrow IPC stream bytes for a one-row table."""
import pyarrow as pa
from pyarrow import ipc

table = pa.table({"x": pa.array([1.0])})
buf = io.BytesIO()
with ipc.new_stream(buf, table.schema) as writer:
Expand Down Expand Up @@ -44,8 +46,6 @@ def readinto(self, b: bytearray) -> int:

def _make_bare(ipc_bytes: bytes):
"""Return a BareExecutionResponse backed by a mock API client."""
from gooddata_sdk.compute.model.execution import BareExecutionResponse

mock_api_client = MagicMock()
mock_response = _FakeResponse(ipc_bytes)
mock_api_client.actions_api.api_client.call_api.return_value = mock_response
Expand All @@ -66,8 +66,6 @@ def _make_bare(ipc_bytes: bytes):

def test_read_result_arrow_returns_table() -> None:
"""read_result_arrow reads the stream from the binary endpoint and returns a pa.Table."""
import pyarrow as pa

ipc_bytes = _make_ipc_stream_bytes()
bare, mock_response = _make_bare(ipc_bytes)

Expand Down Expand Up @@ -101,8 +99,6 @@ def test_read_result_arrow_without_cancel_token() -> None:

def test_read_result_arrow_no_pyarrow_raises() -> None:
"""When pyarrow is not installed, read_result_arrow raises ImportError."""
from gooddata_sdk.compute.model import execution as _exec_mod

ipc_bytes = _make_ipc_stream_bytes()
bare, _ = _make_bare(ipc_bytes)

Expand Down
8 changes: 2 additions & 6 deletions packages/gooddata-sdk/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import pytest
import yaml
from gooddata_sdk import GoodDataSdk
from gooddata_sdk.catalog.data_source.service import CatalogDataSourceService
from tests_support.vcrpy_utils import configure_normalization

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -77,8 +79,6 @@ def _patch_ds_credentials(test_config):
yield
return

from gooddata_sdk.catalog.data_source.service import CatalogDataSourceService

original = CatalogDataSourceService._credentials_from_file

@staticmethod
Expand Down Expand Up @@ -121,8 +121,6 @@ def staging_preflight(test_config, _patch_ds_credentials):
yield
return

from gooddata_sdk import GoodDataSdk

sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])

# 1. Connectivity check
Expand Down Expand Up @@ -235,8 +233,6 @@ def staging_session_snapshot(test_config, staging_preflight):
yield
return

from gooddata_sdk import GoodDataSdk

sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])

# --- Capture ---
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ lint.select = [
"I", # isort
"PERF", # perflint
"PIE",
"PLC0415", # force imports at module top level
"PLR0402", # prevent unnecessary manual import aliases
"PLR1711", # prevent useless returns
"SIM",
Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/tests/test_griffe_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _setup_path(monkeypatch: pytest.MonkeyPatch) -> None:

@pytest.fixture()
def _mod():
import griffe_builder as mod
import griffe_builder as mod # noqa: PLC0415

return mod

Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/tests/test_method_page_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _setup_path(monkeypatch: pytest.MonkeyPatch) -> None:

@pytest.fixture()
def _mod():
import method_page_renderer as mod
import method_page_renderer as mod # noqa: PLC0415

return mod

Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/tests/test_python_ref_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _chdir_to_docs(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture()
def _mod():
"""Lazily import the module (after cwd/syspath are set)."""
import python_ref_builder as mod
import python_ref_builder as mod # noqa: PLC0415

return mod

Expand Down
Loading
Loading