From a401b15ee077e64bd8c22a14e706a4b755e52e11 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 18 Dec 2023 15:28:54 +0200 Subject: [PATCH] pre-commit: use ruff's UP rules instead of pyupgrade --- .pre-commit-config.yaml | 9 +-------- papermill/adl.py | 7 +------ papermill/cli.py | 6 +----- papermill/exceptions.py | 10 +++++----- pyproject.toml | 2 ++ 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b636f1e0..7574a1fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,13 +18,6 @@ repos: - id: check-docstring-first - id: detect-private-key - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - args: ["--py38-plus"] - name: Upgrade code - #- repo: https://github.com/myint/docformatter # rev: v1.5.0 # hooks: @@ -53,7 +46,7 @@ repos: - mdformat_frontmatter - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.8 hooks: - id: ruff args: ["--fix"] diff --git a/papermill/adl.py b/papermill/adl.py index 01efd44d..7dd48962 100644 --- a/papermill/adl.py +++ b/papermill/adl.py @@ -39,12 +39,7 @@ def listdir(self, url): """Returns a list of the files under the specified path""" (store_name, path) = self._split_url(url) adapter = self._create_adapter(store_name) - return [ - "adl://{store_name}.azuredatalakestore.net/{path_to_child}".format( - store_name=store_name, path_to_child=path_to_child - ) - for path_to_child in adapter.ls(path) - ] + return [f"adl://{store_name}.azuredatalakestore.net/{path_to_child}" for path_to_child in adapter.ls(path)] def read(self, url): """Read storage at a given url""" diff --git a/papermill/cli.py b/papermill/cli.py index 8593f543..0c1b54d0 100755 --- a/papermill/cli.py +++ b/papermill/cli.py @@ -26,11 +26,7 @@ def print_papermill_version(ctx, param, value): if not value: return - print( - "{version} from {path} ({pyver})".format( - version=papermill_version, path=__file__, pyver=platform.python_version() - ) - ) + print(f"{papermill_version} from {__file__} ({platform.python_version()})") ctx.exit() diff --git a/papermill/exceptions.py b/papermill/exceptions.py index 26b68cf8..c03fcdf9 100644 --- a/papermill/exceptions.py +++ b/papermill/exceptions.py @@ -59,8 +59,8 @@ class PapermillParameterOverwriteWarning(PapermillWarning): def missing_dependency_generator(package, dep): def missing_dep(): raise PapermillOptionalDependencyException( - "The {package} optional dependency is missing. " - "Please run pip install papermill[{dep}] to install this dependency".format(package=package, dep=dep) + f"The {package} optional dependency is missing. " + f"Please run pip install papermill[{dep}] to install this dependency" ) return missing_dep @@ -69,9 +69,9 @@ def missing_dep(): def missing_environment_variable_generator(package, env_key): def missing_dep(): raise PapermillOptionalDependencyException( - "The {package} optional dependency is present, but the environment " - "variable {env_key} is not set. Please set this variable as " - "required by {package} on your platform.".format(package=package, env_key=env_key) + f"The {package} optional dependency is present, but the environment " + f"variable {env_key} is not set. Please set this variable as " + f"required by {package} on your platform." ) return missing_dep diff --git a/pyproject.toml b/pyproject.toml index 2e1ea524..18e02d6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ ignore-words-list = "dne, compiletime" [tool.ruff] +target-version = "py38" line-length = 120 # Enable Pyflakes `E` and `F` codes by default. select = [ @@ -48,6 +49,7 @@ select = [ # "D", # see: https://pypi.org/project/pydocstyle # "N", # see: https://pypi.org/project/pep8-naming "RUF100", # unnecessary noqa comment + "UP", # pyupgrade ] #extend-select = [ # "C4", # see: https://pypi.org/project/flake8-comprehensions