From 7d0ef65c710ccf9b14a467e0b9f6c9b70d651448 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 20 Aug 2024 14:53:30 +0200 Subject: [PATCH] pre-commit autoupdate 2024-08-16 (#4102) Signed-off-by: Christian Clauss --- .pre-commit-config.yaml | 2 +- .../add_kedro_to_a_notebook.ipynb | 40 +++++++++---------- features/environment.py | 6 +-- features/steps/sh_run.py | 1 + features/steps/test_plugin/plugin.py | 1 + features/steps/util.py | 4 +- kedro/config/abstract_config.py | 1 + kedro/config/omegaconf_config.py | 3 +- kedro/framework/__init__.py | 2 +- kedro/framework/cli/__init__.py | 3 +- kedro/framework/cli/catalog.py | 1 + kedro/framework/cli/cli.py | 1 + kedro/framework/cli/hooks/__init__.py | 1 + kedro/framework/cli/hooks/manager.py | 1 + kedro/framework/cli/hooks/markers.py | 1 + kedro/framework/cli/hooks/specs.py | 1 + kedro/framework/cli/jupyter.py | 1 + kedro/framework/cli/micropkg.py | 3 +- kedro/framework/cli/pipeline.py | 1 + kedro/framework/cli/project.py | 1 + kedro/framework/cli/registry.py | 1 + kedro/framework/cli/starters.py | 1 + kedro/framework/cli/utils.py | 3 +- kedro/framework/context/context.py | 1 + kedro/framework/hooks/__init__.py | 1 + kedro/framework/hooks/manager.py | 1 + kedro/framework/hooks/specs.py | 3 +- kedro/framework/project/__init__.py | 1 + kedro/framework/session/__init__.py | 1 + kedro/framework/session/session.py | 13 +++--- kedro/framework/session/shelvestore.py | 1 + kedro/framework/session/store.py | 1 + kedro/framework/startup.py | 1 + kedro/io/__init__.py | 1 + kedro/io/cached_dataset.py | 1 + kedro/io/core.py | 1 + kedro/io/data_catalog.py | 1 + kedro/io/lambda_dataset.py | 3 +- kedro/io/memory_dataset.py | 4 +- kedro/pipeline/modular_pipeline.py | 1 + kedro/pipeline/node.py | 1 + kedro/pipeline/pipeline.py | 1 + kedro/runner/parallel_runner.py | 1 + kedro/runner/runner.py | 1 + kedro/runner/sequential_runner.py | 1 + kedro/runner/thread_runner.py | 1 + kedro/utils.py | 1 + pyproject.toml | 8 ++-- tests/config/test_omegaconf_config.py | 6 +-- tests/conftest.py | 1 + tests/framework/cli/conftest.py | 1 + tests/framework/cli/test_starters.py | 4 +- tests/io/test_data_catalog.py | 6 +-- 53 files changed, 95 insertions(+), 54 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e9434f20e..9cd73b3ad2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ default_stages: [commit, manual] repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.8 + rev: v0.6.1 hooks: - id: ruff name: "ruff on kedro/, tests/ and docs/" diff --git a/docs/source/notebooks_and_ipython/notebook-example/add_kedro_to_a_notebook.ipynb b/docs/source/notebooks_and_ipython/notebook-example/add_kedro_to_a_notebook.ipynb index 4649f672b2..b5082a7ea7 100644 --- a/docs/source/notebooks_and_ipython/notebook-example/add_kedro_to_a_notebook.ipynb +++ b/docs/source/notebooks_and_ipython/notebook-example/add_kedro_to_a_notebook.ipynb @@ -84,6 +84,7 @@ "outputs": [], "source": [ "# Model training\n", + "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split\n", "\n", "X = model_input_table[\n", @@ -102,8 +103,6 @@ "\n", "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=3)\n", "\n", - "from sklearn.linear_model import LinearRegression\n", - "\n", "model = LinearRegression()\n", "model.fit(X_train, y_train)\n", "model.predict(X_test)" @@ -163,10 +162,10 @@ "source": [ "# Using Kedro's DataCatalog\n", "\n", - "from kedro.io import DataCatalog\n", - "\n", "import yaml\n", "\n", + "from kedro.io import DataCatalog\n", + "\n", "# load the configuration file\n", "with open(\"catalog.yml\") as f:\n", " conf_catalog = yaml.safe_load(f)\n", @@ -311,11 +310,11 @@ "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score\n", "\n", "model = LinearRegression()\n", "model.fit(X_train, y_train)\n", "model.predict(X_test)\n", - "from sklearn.metrics import r2_score\n", "\n", "y_pred = model.predict(X_test)\n", "r2_score(y_test, y_pred)" @@ -405,11 +404,11 @@ "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score\n", "\n", "model = LinearRegression()\n", "model.fit(X_train, y_train)\n", "model.predict(X_test)\n", - "from sklearn.metrics import r2_score\n", "\n", "y_pred = model.predict(X_test)\n", "r2_score(y_test, y_pred)" @@ -483,11 +482,11 @@ "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score\n", "\n", "model = LinearRegression()\n", "model.fit(X_train, y_train)\n", "model.predict(X_test)\n", - "from sklearn.metrics import r2_score\n", "\n", "y_pred = model.predict(X_test)\n", "r2_score(y_test, y_pred)" @@ -511,10 +510,10 @@ "source": [ "# Using Kedro's DataCatalog\n", "\n", - "from kedro.io import DataCatalog\n", - "\n", "import yaml\n", "\n", + "from kedro.io import DataCatalog\n", + "\n", "# load the configuration file\n", "with open(\"catalog.yml\") as f:\n", " conf_catalog = yaml.safe_load(f)\n", @@ -684,7 +683,12 @@ "####################\n", "# Data processing #\n", "####################\n", + "from typing import Dict, Tuple\n", + "\n", "import pandas as pd\n", + "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score\n", + "from sklearn.model_selection import train_test_split\n", "\n", "\n", "def _is_true(x: pd.Series) -> pd.Series:\n", @@ -731,11 +735,6 @@ "# Model training and evaluation #\n", "##################################\n", "\n", - "from typing import Dict, Tuple\n", - "from sklearn.linear_model import LinearRegression\n", - "from sklearn.metrics import r2_score\n", - "from sklearn.model_selection import train_test_split\n", - "\n", "\n", "def split_data(data: pd.DataFrame, parameters: Dict) -> Tuple:\n", " X = data[parameters[\"features\"]]\n", @@ -797,6 +796,13 @@ "outputs": [], "source": [ "# Kedro setup for data management and configuration\n", + "from typing import Dict, Tuple\n", + "\n", + "import pandas as pd\n", + "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score\n", + "from sklearn.model_selection import train_test_split\n", + "\n", "from kedro.config import OmegaConfigLoader\n", "from kedro.io import DataCatalog\n", "\n", @@ -820,7 +826,6 @@ "####################\n", "# Data processing #\n", "####################\n", - "import pandas as pd\n", "\n", "\n", "def _is_true(x: pd.Series) -> pd.Series:\n", @@ -867,11 +872,6 @@ "# Model training and evaluation #\n", "##################################\n", "\n", - "from typing import Dict, Tuple\n", - "from sklearn.linear_model import LinearRegression\n", - "from sklearn.metrics import r2_score\n", - "from sklearn.model_selection import train_test_split\n", - "\n", "\n", "def split_data(data: pd.DataFrame, parameters: Dict) -> Tuple:\n", " X = data[parameters[\"features\"]]\n", diff --git a/features/environment.py b/features/environment.py index 0bc8835164..75bd183ed8 100644 --- a/features/environment.py +++ b/features/environment.py @@ -1,4 +1,5 @@ """Behave environment setup commands.""" + from __future__ import annotations import os @@ -96,9 +97,8 @@ def _create_tmp_dir() -> Path: def _setup_minimal_env(context): if os.environ.get("BEHAVE_LOCAL_ENV"): - output = subprocess.check_output( - ["which", "kedro"] # noqa: S603, S607 - ) # equivalent run "which kedro" + # equivalent run "which kedro" + output = subprocess.check_output(["which", "kedro"]) # noqa: S603, S607 output = output.strip().decode("utf8") kedro_install_venv_dir = Path(output).parent.parent context.kedro_install_venv_dir = kedro_install_venv_dir diff --git a/features/steps/sh_run.py b/features/steps/sh_run.py index c6581a8978..b7b31aae34 100644 --- a/features/steps/sh_run.py +++ b/features/steps/sh_run.py @@ -27,6 +27,7 @@ def run( Example: :: "ls" + "ls -la" "chmod 754 local/file" diff --git a/features/steps/test_plugin/plugin.py b/features/steps/test_plugin/plugin.py index 277fb1f18e..0f43dc0059 100644 --- a/features/steps/test_plugin/plugin.py +++ b/features/steps/test_plugin/plugin.py @@ -1,4 +1,5 @@ """Dummy plugin with simple hook implementations.""" + import logging from pathlib import Path diff --git a/features/steps/util.py b/features/steps/util.py index ab659b2cb0..437b3f6f5e 100644 --- a/features/steps/util.py +++ b/features/steps/util.py @@ -1,5 +1,5 @@ -"""Common functions for e2e testing. -""" +"""Common functions for e2e testing.""" + from __future__ import annotations import os diff --git a/kedro/config/abstract_config.py b/kedro/config/abstract_config.py index a7edf83187..100025be9a 100644 --- a/kedro/config/abstract_config.py +++ b/kedro/config/abstract_config.py @@ -1,6 +1,7 @@ """This module provides ``kedro.abstract_config`` with the baseline class model for a `ConfigLoader` implementation. """ + from __future__ import annotations from collections import UserDict diff --git a/kedro/config/omegaconf_config.py b/kedro/config/omegaconf_config.py index 51fae73906..44259b3bad 100644 --- a/kedro/config/omegaconf_config.py +++ b/kedro/config/omegaconf_config.py @@ -1,6 +1,7 @@ """This module provides ``kedro.config`` with the functionality to load one or more configuration files of yaml or json type from specified paths through OmegaConf. """ + from __future__ import annotations import io @@ -269,7 +270,7 @@ def keys(self) -> KeysView: return KeysView(self.config_patterns) @typing.no_type_check - def load_and_merge_dir_config( # noqa: PLR0913 + def load_and_merge_dir_config( self, conf_path: str, patterns: Iterable[str], diff --git a/kedro/framework/__init__.py b/kedro/framework/__init__.py index 0de0f8cbf9..a58c0161de 100644 --- a/kedro/framework/__init__.py +++ b/kedro/framework/__init__.py @@ -1 +1 @@ -"""``kedro.framework`` provides Kedro's framework components """ +"""``kedro.framework`` provides Kedro's framework components""" diff --git a/kedro/framework/cli/__init__.py b/kedro/framework/cli/__init__.py index 8816ace3ea..1b17af8e0d 100644 --- a/kedro/framework/cli/__init__.py +++ b/kedro/framework/cli/__init__.py @@ -1,5 +1,4 @@ -"""``kedro.framework.cli`` implements commands available from Kedro's CLI. -""" +"""``kedro.framework.cli`` implements commands available from Kedro's CLI.""" # The constant need to be defined first otherwise it causes circular depdencies ORANGE = (255, 175, 0) diff --git a/kedro/framework/cli/catalog.py b/kedro/framework/cli/catalog.py index 020e62270c..223980dade 100644 --- a/kedro/framework/cli/catalog.py +++ b/kedro/framework/cli/catalog.py @@ -1,4 +1,5 @@ """A collection of CLI commands for working with Kedro catalog.""" + from __future__ import annotations import copy diff --git a/kedro/framework/cli/cli.py b/kedro/framework/cli/cli.py index 8fd21acb68..2ef5ee66dc 100644 --- a/kedro/framework/cli/cli.py +++ b/kedro/framework/cli/cli.py @@ -2,6 +2,7 @@ This module implements commands available from the kedro CLI. """ + from __future__ import annotations import importlib diff --git a/kedro/framework/cli/hooks/__init__.py b/kedro/framework/cli/hooks/__init__.py index 7a6ed8a52d..66472e89b2 100644 --- a/kedro/framework/cli/hooks/__init__.py +++ b/kedro/framework/cli/hooks/__init__.py @@ -1,4 +1,5 @@ """``kedro.framework.cli.hooks`` provides primitives to use hooks to extend KedroCLI's behaviour""" + from .manager import CLIHooksManager, get_cli_hook_manager from .markers import cli_hook_impl diff --git a/kedro/framework/cli/hooks/manager.py b/kedro/framework/cli/hooks/manager.py index ba21adc356..e7e691ef1a 100644 --- a/kedro/framework/cli/hooks/manager.py +++ b/kedro/framework/cli/hooks/manager.py @@ -1,4 +1,5 @@ """This module defines a dedicated hook manager for hooks that extends Kedro CLI behaviour.""" + import logging from pluggy import PluginManager diff --git a/kedro/framework/cli/hooks/markers.py b/kedro/framework/cli/hooks/markers.py index dca1769e5e..8e006b186e 100644 --- a/kedro/framework/cli/hooks/markers.py +++ b/kedro/framework/cli/hooks/markers.py @@ -2,6 +2,7 @@ For more information, please see [Pluggy's documentation](https://pluggy.readthedocs.io/en/stable/#marking-hooks). """ + import pluggy CLI_HOOK_NAMESPACE = "kedro_cli" diff --git a/kedro/framework/cli/hooks/specs.py b/kedro/framework/cli/hooks/specs.py index 73e750557b..9361935bfc 100644 --- a/kedro/framework/cli/hooks/specs.py +++ b/kedro/framework/cli/hooks/specs.py @@ -2,6 +2,7 @@ For more information about these specifications, please visit [Pluggy's documentation](https://pluggy.readthedocs.io/en/stable/#specs) """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/kedro/framework/cli/jupyter.py b/kedro/framework/cli/jupyter.py index 91c62c4af3..065277b6fb 100644 --- a/kedro/framework/cli/jupyter.py +++ b/kedro/framework/cli/jupyter.py @@ -1,6 +1,7 @@ """A collection of helper functions to integrate with Jupyter/IPython and CLI commands for working with Kedro catalog. """ + from __future__ import annotations import json diff --git a/kedro/framework/cli/micropkg.py b/kedro/framework/cli/micropkg.py index b826753cc6..d2733ff712 100644 --- a/kedro/framework/cli/micropkg.py +++ b/kedro/framework/cli/micropkg.py @@ -1,4 +1,5 @@ """A collection of CLI commands for working with Kedro micro-packages.""" + # ruff: noqa: I001 from __future__ import annotations @@ -410,7 +411,7 @@ def safe_extract(tar: tarfile.TarFile, path: Path) -> None: if not _is_within_directory(path, member_path): raise Exception("Failed to safely extract tar file.") safe_members.append(member) - tar.extractall(path, members=safe_members) # nosec B202 + tar.extractall(path, members=safe_members) # noqa S202 # The nosec is still required because bandit still flags this. # Related issue: https://github.com/PyCQA/bandit/issues/1038 diff --git a/kedro/framework/cli/pipeline.py b/kedro/framework/cli/pipeline.py index b2b9e64956..7a377b943f 100644 --- a/kedro/framework/cli/pipeline.py +++ b/kedro/framework/cli/pipeline.py @@ -1,4 +1,5 @@ """A collection of CLI commands for working with Kedro pipelines.""" + from __future__ import annotations import re diff --git a/kedro/framework/cli/project.py b/kedro/framework/cli/project.py index 482dc9e270..45a41b19d4 100644 --- a/kedro/framework/cli/project.py +++ b/kedro/framework/cli/project.py @@ -1,4 +1,5 @@ """A collection of CLI commands for working with Kedro project.""" + from __future__ import annotations import os diff --git a/kedro/framework/cli/registry.py b/kedro/framework/cli/registry.py index 2c1c576574..e09b152bcd 100644 --- a/kedro/framework/cli/registry.py +++ b/kedro/framework/cli/registry.py @@ -1,4 +1,5 @@ """A collection of CLI commands for working with registered Kedro pipelines.""" + from typing import Any import click diff --git a/kedro/framework/cli/starters.py b/kedro/framework/cli/starters.py index 51e27884f6..fbafbb56c1 100644 --- a/kedro/framework/cli/starters.py +++ b/kedro/framework/cli/starters.py @@ -3,6 +3,7 @@ This module implements commands available from the kedro CLI for creating projects. """ + from __future__ import annotations import logging diff --git a/kedro/framework/cli/utils.py b/kedro/framework/cli/utils.py index 8637c63a85..e165c15579 100644 --- a/kedro/framework/cli/utils.py +++ b/kedro/framework/cli/utils.py @@ -1,4 +1,5 @@ """Utilities for use with click.""" + from __future__ import annotations import difflib @@ -442,7 +443,7 @@ def _config_file_callback(ctx: click.Context, param: Any, value: Any) -> Any: if value: config = OmegaConf.to_container(OmegaConf.load(value))[section] - for key, value in config.items(): + for key, value in config.items(): # noqa: PLR1704 _validate_config_file(key) ctx.default_map.update(config) diff --git a/kedro/framework/context/context.py b/kedro/framework/context/context.py index 7cb0720e07..3b61b747f6 100644 --- a/kedro/framework/context/context.py +++ b/kedro/framework/context/context.py @@ -1,4 +1,5 @@ """This module provides context for Kedro project.""" + from __future__ import annotations import logging diff --git a/kedro/framework/hooks/__init__.py b/kedro/framework/hooks/__init__.py index 8ce7a9b695..000d9d8b54 100644 --- a/kedro/framework/hooks/__init__.py +++ b/kedro/framework/hooks/__init__.py @@ -1,4 +1,5 @@ """``kedro.framework.hooks`` provides primitives to use hooks to extend KedroContext's behaviour""" + from .manager import _create_hook_manager from .markers import hook_impl diff --git a/kedro/framework/hooks/manager.py b/kedro/framework/hooks/manager.py index 64a63257be..5cbbcf9f27 100644 --- a/kedro/framework/hooks/manager.py +++ b/kedro/framework/hooks/manager.py @@ -1,6 +1,7 @@ """This module provides an utility function to retrieve the global hook_manager singleton in a Kedro's execution process. """ + import logging from typing import Any, Iterable diff --git a/kedro/framework/hooks/specs.py b/kedro/framework/hooks/specs.py index 0d8946cfdb..b0037a0878 100644 --- a/kedro/framework/hooks/specs.py +++ b/kedro/framework/hooks/specs.py @@ -2,6 +2,7 @@ For more information about these specifications, please visit [Pluggy's documentation](https://pluggy.readthedocs.io/en/stable/#specs) """ + from __future__ import annotations from typing import TYPE_CHECKING, Any @@ -49,7 +50,7 @@ class NodeSpecs: """Namespace that defines all specifications for a node's lifecycle hooks.""" @hook_spec - def before_node_run( # noqa: PLR0913 + def before_node_run( self, node: Node, catalog: DataCatalog, diff --git a/kedro/framework/project/__init__.py b/kedro/framework/project/__init__.py index 8ca08b3be8..a3248b9daf 100644 --- a/kedro/framework/project/__init__.py +++ b/kedro/framework/project/__init__.py @@ -1,5 +1,6 @@ """``kedro.framework.project`` module provides utility to configure a Kedro project and access its settings.""" + from __future__ import annotations import importlib diff --git a/kedro/framework/session/__init__.py b/kedro/framework/session/__init__.py index b195660d3c..7afdd72cf1 100644 --- a/kedro/framework/session/__init__.py +++ b/kedro/framework/session/__init__.py @@ -1,6 +1,7 @@ """``kedro.framework.session`` provides access to KedroSession responsible for project lifecycle. """ + from .session import KedroSession __all__ = ["KedroSession"] diff --git a/kedro/framework/session/session.py b/kedro/framework/session/session.py index 4880ce1948..23ac653d20 100644 --- a/kedro/framework/session/session.py +++ b/kedro/framework/session/session.py @@ -1,4 +1,5 @@ """This module implements Kedro session responsible for project lifecycle.""" + from __future__ import annotations import getpass @@ -35,14 +36,14 @@ def _describe_git(project_path: Path) -> dict[str, dict[str, Any]]: path = str(project_path) try: - res = subprocess.check_output( - ["git", "rev-parse", "--short", "HEAD"], # noqa: S603, S607 + res = subprocess.check_output( # noqa: S603 + ["git", "rev-parse", "--short", "HEAD"], # noqa: S607 cwd=path, stderr=subprocess.STDOUT, ) git_data: dict[str, Any] = {"commit_sha": res.decode().strip()} - git_status_res = subprocess.check_output( - ["git", "status", "--short"], # noqa: S603, S607 + git_status_res = subprocess.check_output( # noqa: S603 + ["git", "status", "--short"], # noqa: S607 cwd=path, stderr=subprocess.STDOUT, ) @@ -99,7 +100,7 @@ class KedroSession: """ - def __init__( # noqa: PLR0913 + def __init__( self, session_id: str, package_name: str | None = None, @@ -126,7 +127,7 @@ def __init__( # noqa: PLR0913 ) @classmethod - def create( # noqa: PLR0913 + def create( cls, project_path: Path | str | None = None, save_on_close: bool = True, diff --git a/kedro/framework/session/shelvestore.py b/kedro/framework/session/shelvestore.py index 722a663496..5fbac073ef 100644 --- a/kedro/framework/session/shelvestore.py +++ b/kedro/framework/session/shelvestore.py @@ -1,6 +1,7 @@ """This module implements a dict-like store object used to persist Kedro sessions. This module is separated from store.py to ensure it's only imported when exported explicitly. """ + from __future__ import annotations import dbm diff --git a/kedro/framework/session/store.py b/kedro/framework/session/store.py index b0b82fc663..9d94b99697 100644 --- a/kedro/framework/session/store.py +++ b/kedro/framework/session/store.py @@ -1,4 +1,5 @@ """This module implements a dict-like store object used to persist Kedro sessions.""" + from __future__ import annotations import logging diff --git a/kedro/framework/startup.py b/kedro/framework/startup.py index 32d4be0b21..b1842f3dc5 100644 --- a/kedro/framework/startup.py +++ b/kedro/framework/startup.py @@ -1,4 +1,5 @@ """This module provides metadata for a Kedro project.""" + from __future__ import annotations import os diff --git a/kedro/io/__init__.py b/kedro/io/__init__.py index 7902f866bd..aba59827e9 100644 --- a/kedro/io/__init__.py +++ b/kedro/io/__init__.py @@ -1,6 +1,7 @@ """``kedro.io`` provides functionality to read and write to a number of data sets. At the core of the library is the ``AbstractDataset`` class. """ + from __future__ import annotations from .cached_dataset import CachedDataset diff --git a/kedro/io/cached_dataset.py b/kedro/io/cached_dataset.py index c4424c34ef..5f8d96dc36 100644 --- a/kedro/io/cached_dataset.py +++ b/kedro/io/cached_dataset.py @@ -2,6 +2,7 @@ This module contains ``CachedDataset``, a dataset wrapper which caches in memory the data saved, so that the user avoids io operations with slow storage media """ + from __future__ import annotations import logging diff --git a/kedro/io/core.py b/kedro/io/core.py index ef87cd4df8..f3975c9c3c 100644 --- a/kedro/io/core.py +++ b/kedro/io/core.py @@ -1,6 +1,7 @@ """This module provides a set of classes which underpin the data loading and saving functionality provided by ``kedro.io``. """ + from __future__ import annotations import abc diff --git a/kedro/io/data_catalog.py b/kedro/io/data_catalog.py index ba745f43bd..d3fd163230 100644 --- a/kedro/io/data_catalog.py +++ b/kedro/io/data_catalog.py @@ -4,6 +4,7 @@ sets. Then it will act as a single point of reference for your calls, relaying load and save functions to the underlying data sets. """ + from __future__ import annotations import copy diff --git a/kedro/io/lambda_dataset.py b/kedro/io/lambda_dataset.py index 9c6ee10498..043bb67737 100644 --- a/kedro/io/lambda_dataset.py +++ b/kedro/io/lambda_dataset.py @@ -2,6 +2,7 @@ providing custom load, save, and exists methods without extending ``AbstractDataset``. """ + from __future__ import annotations from typing import Any, Callable @@ -76,7 +77,7 @@ def _release(self) -> None: else: self.__release() - def __init__( # noqa: PLR0913 + def __init__( self, load: Callable[[], Any] | None, save: Callable[[Any], None] | None, diff --git a/kedro/io/memory_dataset.py b/kedro/io/memory_dataset.py index 30b6e19fa8..56ad92b7f2 100644 --- a/kedro/io/memory_dataset.py +++ b/kedro/io/memory_dataset.py @@ -1,5 +1,5 @@ -"""``MemoryDataset`` is a data set implementation which handles in-memory data. -""" +"""``MemoryDataset`` is a data set implementation which handles in-memory data.""" + from __future__ import annotations import copy diff --git a/kedro/pipeline/modular_pipeline.py b/kedro/pipeline/modular_pipeline.py index 779800aa35..172a5f9593 100644 --- a/kedro/pipeline/modular_pipeline.py +++ b/kedro/pipeline/modular_pipeline.py @@ -1,4 +1,5 @@ """Helper to integrate modular pipelines into a master pipeline.""" + from __future__ import annotations import copy diff --git a/kedro/pipeline/node.py b/kedro/pipeline/node.py index 5643aeb7fc..09a83410aa 100644 --- a/kedro/pipeline/node.py +++ b/kedro/pipeline/node.py @@ -1,6 +1,7 @@ """This module provides user-friendly functions for creating nodes as parts of Kedro pipelines. """ + from __future__ import annotations import copy diff --git a/kedro/pipeline/pipeline.py b/kedro/pipeline/pipeline.py index cab109deb5..7810a98049 100644 --- a/kedro/pipeline/pipeline.py +++ b/kedro/pipeline/pipeline.py @@ -3,6 +3,7 @@ offers quick access to input dependencies, produced outputs and execution order. """ + from __future__ import annotations import json diff --git a/kedro/runner/parallel_runner.py b/kedro/runner/parallel_runner.py index 6d8d7c7142..62d7e1216b 100644 --- a/kedro/runner/parallel_runner.py +++ b/kedro/runner/parallel_runner.py @@ -1,6 +1,7 @@ """``ParallelRunner`` is an ``AbstractRunner`` implementation. It can be used to run the ``Pipeline`` in parallel groups formed by toposort. """ + from __future__ import annotations import multiprocessing diff --git a/kedro/runner/runner.py b/kedro/runner/runner.py index 870d2e6d35..2ffd0389e4 100644 --- a/kedro/runner/runner.py +++ b/kedro/runner/runner.py @@ -1,6 +1,7 @@ """``AbstractRunner`` is the base class for all ``Pipeline`` runner implementations. """ + from __future__ import annotations import inspect diff --git a/kedro/runner/sequential_runner.py b/kedro/runner/sequential_runner.py index 894b2d8552..48dac3cd54 100644 --- a/kedro/runner/sequential_runner.py +++ b/kedro/runner/sequential_runner.py @@ -2,6 +2,7 @@ used to run the ``Pipeline`` in a sequential manner using a topological sort of provided nodes. """ + from __future__ import annotations from collections import Counter diff --git a/kedro/runner/thread_runner.py b/kedro/runner/thread_runner.py index 86c56b553f..b4751a602a 100644 --- a/kedro/runner/thread_runner.py +++ b/kedro/runner/thread_runner.py @@ -2,6 +2,7 @@ be used to run the ``Pipeline`` in parallel groups formed by toposort using threads. """ + from __future__ import annotations import warnings diff --git a/kedro/utils.py b/kedro/utils.py index ad513b81dd..2d99d3d4e6 100644 --- a/kedro/utils.py +++ b/kedro/utils.py @@ -1,6 +1,7 @@ """This module provides a set of helper functions being used across different components of kedro package. """ + import importlib import logging import os diff --git a/pyproject.toml b/pyproject.toml index 9f8120fa22..8b7b4cb09b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -215,7 +215,7 @@ ignore_imports = [ [tool.ruff] line-length = 88 show-fixes = true -select = [ +lint.select = [ "F", # Pyflakes "W", # pycodestyle "E", # pycodestyle @@ -227,12 +227,12 @@ select = [ "TCH", # flake8-type-checking "RUF", # Ruff-specific rules ] -ignore = ["E501"] +lint.ignore = ["E501"] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["kedro"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "{tests,docs}/*" = ["PLR2004","PLR0913"] "{tests,docs,tools,static,features,docs}/*" = ["T201", "S101", "S108"] # Check print statement for kedro/ only diff --git a/tests/config/test_omegaconf_config.py b/tests/config/test_omegaconf_config.py index 1c0b26a6d7..c2e509d9bf 100644 --- a/tests/config/test_omegaconf_config.py +++ b/tests/config/test_omegaconf_config.py @@ -649,8 +649,8 @@ def test_env_resolver_is_registered_after_loading(self, tmp_path): @use_config_dir def test_load_config_from_tar_file(self, tmp_path): - subprocess.run( # noqa: PLW1510 - [ # noqa: S603, S607 + subprocess.run( # noqa: PLW1510,S603 + [ # noqa: S607 "tar", "--exclude=local/*.yml", "-czf", @@ -1029,7 +1029,7 @@ def test_ignore_ipynb_checkpoints(self, tmp_path, mocker): # read successfully conf["parameters"] - mocker.patch.object(conf, "_is_hidden", return_value=False) # + mocker.patch.object(conf, "_is_hidden", return_value=False) with pytest.raises(ValueError, match="Duplicate keys found in"): # fail because of reading the hidden files and get duplicate keys conf["parameters"] diff --git a/tests/conftest.py b/tests/conftest.py index 255cd9c395..083713d74a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,6 +4,7 @@ discover them automatically. More info here: https://docs.pytest.org/en/latest/fixture.html """ + import os import sys diff --git a/tests/framework/cli/conftest.py b/tests/framework/cli/conftest.py index 2db22389f9..effdfd3f28 100644 --- a/tests/framework/cli/conftest.py +++ b/tests/framework/cli/conftest.py @@ -4,6 +4,7 @@ discover them automatically. More info here: https://docs.pytest.org/en/latest/fixture.html """ + import shutil import sys import tempfile diff --git a/tests/framework/cli/test_starters.py b/tests/framework/cli/test_starters.py index f17e133370..32f618d68f 100644 --- a/tests/framework/cli/test_starters.py +++ b/tests/framework/cli/test_starters.py @@ -1,5 +1,5 @@ -"""This module contains unit test for the cli command 'kedro new' -""" +"""This module contains unit test for the cli command 'kedro new'""" + from __future__ import annotations import logging diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index aaa1fed15d..dbec57e64d 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -487,9 +487,9 @@ def test_config_missing_type(self, sane_config): def test_config_invalid_module(self, sane_config): """Check the error if the type points to nonexistent module""" - sane_config["catalog"]["boats"][ - "type" - ] = "kedro.invalid_module_name.io.CSVDataset" + sane_config["catalog"]["boats"]["type"] = ( + "kedro.invalid_module_name.io.CSVDataset" + ) error_msg = "Class 'kedro.invalid_module_name.io.CSVDataset' not found" with pytest.raises(DatasetError, match=re.escape(error_msg)):