Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#175)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.2](astral-sh/ruff-pre-commit@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 <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and mscheltienne authored Apr 30, 2024
1 parent 2c16941 commit d8ae0cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pycrostates/utils/_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -152,15 +152,15 @@ 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}. "
"{options}, but got {item!r} instead."
)
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])} "
Expand Down

0 comments on commit d8ae0cd

Please sign in to comment.