Skip to content

Commit c36147d

Browse files
authored
Merge pull request #3214 from python-trio/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents 1b82247 + f10e48a commit c36147d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
hooks:
2525
- id: black
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.9.6
27+
rev: v0.9.7
2828
hooks:
2929
- id: ruff
3030
types: [file]
@@ -38,7 +38,7 @@ repos:
3838
# tomli needed on 3.10. tomllib is available in stdlib on 3.11+
3939
- tomli
4040
- repo: https://github.com/crate-ci/typos
41-
rev: typos-dict-v0.12.5
41+
rev: v1.29.9
4242
hooks:
4343
- id: typos
4444
- repo: https://github.com/sphinx-contrib/sphinx-lint
@@ -59,7 +59,7 @@ repos:
5959
additional_dependencies: ["astor", "attrs", "black", "ruff"]
6060
files: ^src\/trio\/_core\/(_run|(_i(o_(common|epoll|kqueue|windows)|nstrumentation)))\.py$
6161
- repo: https://github.com/astral-sh/uv-pre-commit
62-
rev: 0.6.1
62+
rev: 0.6.2
6363
hooks:
6464
# Compile requirements
6565
- id: pip-compile

src/trio/_core/_instrumentation.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import logging
44
import types
5+
from collections import UserDict
56
from typing import TYPE_CHECKING, TypeVar
67

78
from .._abc import Instrument
@@ -21,7 +22,7 @@ def _public(fn: T) -> T:
2122
return fn
2223

2324

24-
class Instruments(dict[str, dict[Instrument, None]]):
25+
class Instruments(UserDict[str, dict[Instrument, None]]):
2526
"""A collection of `trio.abc.Instrument` organized by hook.
2627
2728
Instrumentation calls are rather expensive, and we don't want a
@@ -34,7 +35,7 @@ class Instruments(dict[str, dict[Instrument, None]]):
3435
__slots__ = ()
3536

3637
def __init__(self, incoming: Sequence[Instrument]) -> None:
37-
self["_all"] = {}
38+
super().__init__({"_all": {}})
3839
for instrument in incoming:
3940
self.add_instrument(instrument)
4041

@@ -48,9 +49,9 @@ def add_instrument(self, instrument: Instrument) -> None:
4849
If ``instrument`` is already active, does nothing.
4950
5051
"""
51-
if instrument in self["_all"]:
52+
if instrument in self.data["_all"]:
5253
return
53-
self["_all"][instrument] = None
54+
self.data["_all"][instrument] = None
5455
try:
5556
for name in dir(instrument):
5657
if name.startswith("_"):
@@ -63,7 +64,7 @@ def add_instrument(self, instrument: Instrument) -> None:
6364
if isinstance(impl, types.MethodType) and impl.__func__ is prototype:
6465
# Inherited unchanged from _abc.Instrument
6566
continue
66-
self.setdefault(name, {})[instrument] = None
67+
self.data.setdefault(name, {})[instrument] = None
6768
except:
6869
self.remove_instrument(instrument)
6970
raise
@@ -83,12 +84,12 @@ def remove_instrument(self, instrument: Instrument) -> None:
8384
8485
"""
8586
# If instrument isn't present, the KeyError propagates out
86-
self["_all"].pop(instrument)
87-
for hookname, instruments in list(self.items()):
87+
self.data["_all"].pop(instrument)
88+
for hookname, instruments in list(self.data.items()):
8889
if instrument in instruments:
8990
del instruments[instrument]
9091
if not instruments:
91-
del self[hookname]
92+
del self.data[hookname]
9293

9394
def call(
9495
self,
@@ -103,7 +104,7 @@ def call(
103104
if "before_task_step" in instruments:
104105
instruments.call("before_task_step", task)
105106
"""
106-
for instrument in list(self[hookname]):
107+
for instrument in list(self.data[hookname]):
107108
try:
108109
getattr(instrument, hookname)(*args)
109110
except BaseException:

test-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pyyaml==6.0.2
130130
# via pre-commit
131131
requests==2.32.3
132132
# via sphinx
133-
ruff==0.9.6
133+
ruff==0.9.7
134134
# via -r test-requirements.in
135135
sniffio==1.3.1
136136
# via -r test-requirements.in
@@ -186,7 +186,7 @@ typing-extensions==4.12.2
186186
# pyright
187187
urllib3==2.3.0
188188
# via requests
189-
uv==0.6.1
189+
uv==0.6.2
190190
# via -r test-requirements.in
191191
virtualenv==20.29.2
192192
# via pre-commit

0 commit comments

Comments
 (0)