diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3d164864d..499c588e79 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.0 + rev: v0.3.2 hooks: - id: ruff types: [file] diff --git a/src/trio/_channel.py b/src/trio/_channel.py index 7eb8199461..f5ed4004d7 100644 --- a/src/trio/_channel.py +++ b/src/trio/_channel.py @@ -299,8 +299,8 @@ def statistics(self) -> MemoryChannelStats: return self._state.statistics() def __repr__(self) -> str: - return "".format( - id(self), id(self._state) + return ( + f"" ) @enable_ki_protection diff --git a/src/trio/_core/_mock_clock.py b/src/trio/_core/_mock_clock.py index deb239c417..70c4e58a2d 100644 --- a/src/trio/_core/_mock_clock.py +++ b/src/trio/_core/_mock_clock.py @@ -79,9 +79,7 @@ def __init__(self, rate: float = 0.0, autojump_threshold: float = inf): self.autojump_threshold = autojump_threshold def __repr__(self) -> str: - return "".format( - self.current_time(), self._rate, id(self) - ) + return f"" @property def rate(self) -> float: diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index c5d6b65712..9d27793d82 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -585,13 +585,8 @@ def _close(self, exc: BaseException | None) -> BaseException | None: # we just need to make sure we don't let the error # pass silently. new_exc = RuntimeError( - "Cancel scope stack corrupted: attempted to exit {!r} " - "in {!r} that's still within its child {!r}\n{}".format( - self, - scope_task, - scope_task._cancel_status._scope, - MISNESTING_ADVICE, - ) + f"Cancel scope stack corrupted: attempted to exit {self!r} " + f"in {scope_task!r} that's still within its child {scope_task._cancel_status._scope!r}\n{MISNESTING_ADVICE}" ) new_exc.__context__ = exc exc = new_exc diff --git a/src/trio/_deprecate.py b/src/trio/_deprecate.py index 6ed496d353..9a19f219c9 100644 --- a/src/trio/_deprecate.py +++ b/src/trio/_deprecate.py @@ -97,9 +97,7 @@ def wrapper(*args: ArgsT.args, **kwargs: ArgsT.kwargs) -> RetT: if instead is not None: doc += f" Use {_stringify(instead)} instead.\n" if issue is not None: - doc += " For details, see `issue #{} <{}>`__.\n".format( - issue, _url_for_issue(issue) - ) + doc += f" For details, see `issue #{issue} <{_url_for_issue(issue)}>`__.\n" doc += "\n" wrapper.__doc__ = doc diff --git a/src/trio/_sync.py b/src/trio/_sync.py index 86ba7026c6..6e62eceeff 100644 --- a/src/trio/_sync.py +++ b/src/trio/_sync.py @@ -223,9 +223,7 @@ def __init__(self, total_tokens: int | float): # noqa: PYI041 assert self._total_tokens == total_tokens def __repr__(self) -> str: - return "".format( - id(self), len(self._borrowers), self._total_tokens, len(self._lot) - ) + return f"" @property def total_tokens(self) -> int | float: diff --git a/src/trio/_threads.py b/src/trio/_threads.py index e5c3b30017..b002a58552 100644 --- a/src/trio/_threads.py +++ b/src/trio/_threads.py @@ -475,8 +475,7 @@ def abort(raise_cancel: RaiseCancelT) -> trio.lowlevel.Abort: msg_from_thread.run_sync() else: # pragma: no cover, internal debugging guard TODO: use assert_never raise TypeError( - "trio.to_thread.run_sync received unrecognized thread message {!r}." - "".format(msg_from_thread) + f"trio.to_thread.run_sync received unrecognized thread message {msg_from_thread!r}." ) del msg_from_thread diff --git a/src/trio/_util.py b/src/trio/_util.py index c9fdb3557b..e0f6c23800 100644 --- a/src/trio/_util.py +++ b/src/trio/_util.py @@ -247,11 +247,7 @@ def decorator(func: CallT) -> CallT: func.__name__ = attr_name func.__qualname__ = ".".join((cls.__qualname__, attr_name)) - func.__doc__ = """Like :meth:`~{}.{}.{}`, but async. - - """.format( - wrapped_cls.__module__, wrapped_cls.__qualname__, attr_name - ) + func.__doc__ = f"Like :meth:`~{wrapped_cls.__module__}.{wrapped_cls.__qualname__}.{attr_name}`, but async." return func