From d8ae0cd0d81fdc8d5ccfc4f40fd6f9d4197f71c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:32:29 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.1...v0.4.2) * fix ruff --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Mathieu Scheltienne --- .pre-commit-config.yaml | 2 +- pycrostates/utils/_checks.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 794e4bd5..fc0141b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: files: pycrostates - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.1 + rev: v0.4.2 hooks: - id: ruff name: ruff linter diff --git a/pycrostates/utils/_checks.py b/pycrostates/utils/_checks.py index 82e48d63..4f5ec192 100644 --- a/pycrostates/utils/_checks.py +++ b/pycrostates/utils/_checks.py @@ -42,7 +42,7 @@ def _ensure_int(item, item_name=None): raise TypeError item = int(operator.index(item)) except TypeError: - item_name = "Item" if item_name is None else "'%s'" % item_name + item_name = "Item" if item_name is None else f"'{item_name}'" raise TypeError(f"{item_name} must be an int, got {type(item)} instead.") return item @@ -122,7 +122,7 @@ def _check_type(item, types, item_name=None): else: type_name[-1] = "or " + type_name[-1] type_name = ", ".join(type_name) - item_name = "Item" if item_name is None else "'%s'" % item_name + item_name = "Item" if item_name is None else f"'{item_name}'" raise TypeError( f"{item_name} must be an instance of {type_name}, " f"got {type(item)} instead." @@ -152,7 +152,7 @@ def _check_value(item, allowed_values, item_name=None, extra=None): When the value of the item is not one of the valid options. """ if item not in allowed_values: - item_name = "" if item_name is None else " '%s'" % item_name + item_name = "" if item_name is None else f" '{item_name}'" extra = "" if extra is None else " " + extra msg = ( "Invalid value for the{item_name} parameter{extra}. " @@ -160,7 +160,7 @@ def _check_value(item, allowed_values, item_name=None, extra=None): ) allowed_values = tuple(allowed_values) # e.g., if a dict was given if len(allowed_values) == 1: - options = "The only allowed value is %s" % repr(allowed_values[0]) + options = f"The only allowed value is {repr(allowed_values[0])}" elif len(allowed_values) == 2: options = ( f"Allowed values are {repr(allowed_values[0])} "