Skip to content

Commit acc0463

Browse files
authored
Merge pull request #770 from hkad98/ruff-improvements
Enable some rules for ruff
2 parents 73e61db + a57bda4 commit acc0463

58 files changed

Lines changed: 147 additions & 173 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gooddata-dbt/gooddata_dbt/args.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ def set_gooddata_endpoint_args(parser: argparse.ArgumentParser) -> None:
3737
)
3838
# Alternative - use profile.yml file
3939
env_profiles = os.getenv("GOODDATA_PROFILES")
40-
if env_profiles:
41-
env_profiles_list = env_profiles.split(" ")
42-
else:
43-
env_profiles_list = []
40+
env_profiles_list = env_profiles.split(" ") if env_profiles else []
4441
parser.add_argument(
4542
"-gp",
4643
"--gooddata-profiles",

gooddata-dbt/tests/test_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

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

1919

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# (C) 2021 GoodData Corporation
2-
try:
3-
from importlib import metadata
4-
except ImportError:
5-
import importlib_metadata as metadata # type: ignore # mypy issue #1153
2+
from importlib import metadata
63

74
__version__: str = metadata.version("gooddata-fdw")

gooddata-fdw/gooddata_fdw/executor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# (C) 2022 GoodData Corporation
22
from __future__ import annotations
33

4-
from typing import Any, Generator, NamedTuple, Optional
4+
from collections.abc import Generator
5+
from typing import Any, NamedTuple, Optional
56

67
from gooddata_sdk import GoodDataSdk
78

gooddata-fdw/gooddata_fdw/fdw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

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

2525
# Table options contain also foreign server options

gooddata-fdw/gooddata_fdw/result_reader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# (C) 2022 GoodData Corporation
22
from __future__ import annotations
33

4-
from typing import Any, Generator
4+
from collections.abc import Generator
5+
from typing import Any
56

67
from gooddata_sdk import ExecutionTable
78
from gooddata_sdk.type_converter import DBTypeConverterStore

gooddata-fdw/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def pytest_addoption(parser):
2020
@pytest.fixture(scope="session")
2121
def test_config(request):
2222
config_path = Path(request.config.getoption("--gd-test-config"))
23-
with open(config_path, "rt") as f:
23+
with open(config_path) as f:
2424
config = yaml.safe_load(f)
2525

2626
return config

gooddata-flight-server/gooddata_flight_server/_version.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# (C) 2024 GoodData Corporation
2-
try:
3-
from importlib import metadata
4-
except ImportError:
5-
import importlib_metadata as metadata # type: ignore # mypy issue #1153
2+
from importlib import metadata
63

74
try:
85
__version__ = metadata.version("gooddata-flight-server")

gooddata-flight-server/gooddata_flight_server/errors/error_code.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ def _init_names(cls: Any) -> Any:
2929

3030

3131
_RetryFlagsLiteral: TypeAlias = Literal["any", "other", "here"]
32+
_FlagsMapping = {
33+
Literal["any"]: _RETRY_ANY_FLAG,
34+
Literal["here"]: _RETRY_HERE_FLAG,
35+
Literal["other"]: _RETRY_OTHER_FLAG,
36+
}
3237

3338

3439
def _get_flags(retry: Optional[_RetryFlagsLiteral] = None) -> int:
35-
if retry == "any":
36-
return _RETRY_ANY_FLAG
37-
elif retry == "here":
38-
return _RETRY_HERE_FLAG
39-
elif retry == "other":
40-
return _RETRY_OTHER_FLAG
41-
42-
return 0x0
40+
return _FlagsMapping.get(retry, 0x0)
4341

4442

4543
def _error_code(code: int, retry: Optional[_RetryFlagsLiteral] = None) -> int:

gooddata-flight-server/gooddata_flight_server/flexfun/flex_fun_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# (C) 2024 GoodData Corporation
22
import importlib
3-
from typing import Iterable
3+
from collections.abc import Iterable
44

55
import structlog
66

0 commit comments

Comments
 (0)