Skip to content

Commit 03dc6f4

Browse files
committed
ruff format
1 parent cfc01e1 commit 03dc6f4

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/zarr/storage/_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None)
4444
return prototype.buffer.from_bytes(f.read())
4545

4646

47-
if sys.platform == 'win32':
47+
if sys.platform == "win32":
4848
# Per the os.rename docs:
4949
# On Windows, if dst exists a FileExistsError is always raised.
5050
_safe_move = os.rename
@@ -64,7 +64,7 @@ def _atomic_write(
6464
mode: Literal["r+b", "wb"],
6565
exclusive: bool = False,
6666
) -> Iterator[BinaryIO]:
67-
tmp_path = path.with_suffix(f'.{uuid.uuid4().hex}.partial')
67+
tmp_path = path.with_suffix(f".{uuid.uuid4().hex}.partial")
6868
try:
6969
with tmp_path.open(mode) as f:
7070
yield f

tests/test_store/test_local.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,42 +114,42 @@ async def test_move(
114114

115115
@pytest.mark.parametrize("exclusive", [True, False])
116116
def test_atomic_write_successful(tmp_path: pathlib.Path, exclusive: bool) -> None:
117-
path = pathlib.Path(tmp_path) / 'data'
118-
with _atomic_write(path, 'wb', exclusive=exclusive) as f:
119-
f.write(b'abc')
120-
assert path.read_bytes() == b'abc'
117+
path = pathlib.Path(tmp_path) / "data"
118+
with _atomic_write(path, "wb", exclusive=exclusive) as f:
119+
f.write(b"abc")
120+
assert path.read_bytes() == b"abc"
121121
assert list(path.parent.iterdir()) == [path] # no temp files
122122

123123

124124
@pytest.mark.parametrize("exclusive", [True, False])
125125
def test_atomic_write_incomplete(tmp_path: pathlib.Path, exclusive: bool) -> None:
126-
path = pathlib.Path(tmp_path) / 'data'
126+
path = pathlib.Path(tmp_path) / "data"
127127
with pytest.raises(RuntimeError): # noqa: PT012
128-
with _atomic_write(path, 'wb', exclusive=exclusive) as f:
129-
f.write(b'a')
128+
with _atomic_write(path, "wb", exclusive=exclusive) as f:
129+
f.write(b"a")
130130
raise RuntimeError
131131
assert not path.exists()
132132
assert list(path.parent.iterdir()) == [] # no temp files
133133

134134

135135
def test_atomic_write_non_exclusive_preexisting(tmp_path: pathlib.Path) -> None:
136-
path = pathlib.Path(tmp_path) / 'data'
137-
with path.open('wb') as f:
138-
f.write(b'xyz')
139-
assert path.read_bytes() == b'xyz'
140-
with _atomic_write(path, 'wb', exclusive=False) as f:
141-
f.write(b'abc')
142-
assert path.read_bytes() == b'abc'
136+
path = pathlib.Path(tmp_path) / "data"
137+
with path.open("wb") as f:
138+
f.write(b"xyz")
139+
assert path.read_bytes() == b"xyz"
140+
with _atomic_write(path, "wb", exclusive=False) as f:
141+
f.write(b"abc")
142+
assert path.read_bytes() == b"abc"
143143
assert list(path.parent.iterdir()) == [path] # no temp files
144144

145145

146146
def test_atomic_write_exclusive_preexisting(tmp_path: pathlib.Path) -> None:
147-
path = pathlib.Path(tmp_path) / 'data'
148-
with path.open('wb') as f:
149-
f.write(b'xyz')
150-
assert path.read_bytes() == b'xyz'
147+
path = pathlib.Path(tmp_path) / "data"
148+
with path.open("wb") as f:
149+
f.write(b"xyz")
150+
assert path.read_bytes() == b"xyz"
151151
with pytest.raises(FileExistsError):
152-
with _atomic_write(path, 'wb', exclusive=True) as f:
153-
f.write(b'abc')
154-
assert path.read_bytes() == b'xyz'
152+
with _atomic_write(path, "wb", exclusive=True) as f:
153+
f.write(b"abc")
154+
assert path.read_bytes() == b"xyz"
155155
assert list(path.parent.iterdir()) == [path] # no temp files

0 commit comments

Comments
 (0)