flatfs 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flatfs
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Minimal filesystem abstraction with pluggable backends, treating paths as keys and file contents as values.
5
5
  License: MIT
6
6
  License-File: LICENSE.txt
7
7
  Keywords: flat,filesystem,abstraction,library
8
8
  Author: Maciej Wiatrzyk
9
9
  Author-email: maciej.wiatrzyk@gmail.com
10
- Requires-Python: >=3.10,<4
10
+ Requires-Python: >=3.9,<4
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Operating System :: OS Independent
@@ -0,0 +1 @@
1
+ __version__ = "0.4.0"
@@ -0,0 +1,17 @@
1
+ from typing import Any, Coroutine, Generic, Optional, Protocol, TypeVar
2
+
3
+ T = TypeVar("T")
4
+ Tco = TypeVar("Tco", covariant=True)
5
+
6
+
7
+ class SupportsAnext(Protocol, Generic[Tco]):
8
+ def __anext__(self) -> Coroutine[Any, Any, Tco]: ...
9
+
10
+
11
+ async def anext(obj: SupportsAnext[T], default: Optional[T] = None) -> T:
12
+ try:
13
+ return await obj.__anext__()
14
+ except StopAsyncIteration:
15
+ if default is not None:
16
+ return default
17
+ raise
@@ -5,7 +5,7 @@ import fnmatch
5
5
  import os
6
6
  import pathlib
7
7
  from queue import Queue
8
- from typing import AsyncGenerator, AsyncIterator, Generator, Iterator, Optional
8
+ from typing import AsyncGenerator, AsyncIterator, Generator, Iterator, Optional, Union
9
9
 
10
10
  from flatfs.exc import PathAccessError, PathNotFoundError
11
11
  from flatfs.interface import FlatFsReaderWriter, Stat
@@ -233,7 +233,7 @@ class AsyncFlatFsAdapter:
233
233
  loop.call_soon_threadsafe(queue.put_nowait, e)
234
234
 
235
235
  loop = asyncio.get_running_loop()
236
- queue: asyncio.Queue[bytes | Exception] = asyncio.Queue()
236
+ queue: asyncio.Queue[Union[bytes, Exception]] = asyncio.Queue()
237
237
  asyncio.create_task(_utils.run_blocking(reader))
238
238
  while True:
239
239
  chunk_or_exc = await queue.get()
@@ -1,10 +1,9 @@
1
1
  import asyncio
2
2
  from contextlib import AbstractAsyncContextManager, AbstractContextManager
3
3
  from queue import Queue
4
- from types import TracebackType
5
- from typing import Iterator, AsyncIterator
4
+ from typing import Iterator, AsyncIterator, Optional
6
5
 
7
- from . import _export, _utils
6
+ from . import _export, _utils, _compat
8
7
  from .interface import SupportsAsyncReadChunks, SupportsAsyncWriteChunks, SupportsReadChunks, SupportsWriteChunks
9
8
 
10
9
  __all__ = export = _export.Export() # type: ignore
@@ -180,9 +179,7 @@ class BufferedWriter(AbstractContextManager):
180
179
  def __enter__(self) -> "BufferedWriter":
181
180
  return self
182
181
 
183
- def __exit__(
184
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
185
- ) -> bool | None:
182
+ def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
186
183
  return self.close()
187
184
 
188
185
  def __write_chunk(self, chunk: bytes):
@@ -234,14 +231,12 @@ class AsyncBufferedWriter(AbstractAsyncContextManager):
234
231
  async def __aenter__(self) -> "AsyncBufferedWriter":
235
232
  return self
236
233
 
237
- async def __aexit__(
238
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
239
- ) -> bool | None:
234
+ async def __aexit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
240
235
  return await self.close()
241
236
 
242
237
  async def __write_chunk(self, chunk: bytes):
243
238
  self.__chunk_queue.put_nowait(chunk)
244
- await anext(self.__writer)
239
+ await _compat.anext(self.__writer)
245
240
 
246
241
  async def write(self, data: bytes) -> int:
247
242
  self.__buffer += data
@@ -292,9 +287,7 @@ class BufferedReader(AbstractContextManager):
292
287
  def __enter__(self) -> "BufferedReader":
293
288
  return self
294
289
 
295
- def __exit__(
296
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
297
- ) -> bool | None:
290
+ def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
298
291
  return self.close()
299
292
 
300
293
  def close(self):
@@ -320,9 +313,7 @@ class AsyncBufferedReader(AbstractAsyncContextManager):
320
313
  async def __aenter__(self) -> "AsyncBufferedReader":
321
314
  return self
322
315
 
323
- async def __aexit__(
324
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
325
- ) -> bool | None:
316
+ async def __aexit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
326
317
  return await self.close()
327
318
 
328
319
  async def close(self):
@@ -331,7 +322,7 @@ class AsyncBufferedReader(AbstractAsyncContextManager):
331
322
 
332
323
  async def read(self, count: int) -> bytes:
333
324
  if not self.__buffer:
334
- self.__buffer = await anext(self.__reader, b"")
325
+ self.__buffer = await _compat.anext(self.__reader, b"")
335
326
  data = self.__buffer[:count]
336
327
  self.__buffer = self.__buffer[count:]
337
328
  return data
@@ -371,9 +362,7 @@ class BufferedTextReader(AbstractContextManager):
371
362
  def __enter__(self) -> "BufferedTextReader":
372
363
  return self
373
364
 
374
- def __exit__(
375
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
376
- ) -> bool | None:
365
+ def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
377
366
  return self.close()
378
367
 
379
368
  def __iter__(self) -> Iterator[str]:
@@ -417,14 +406,12 @@ class AsyncBufferedTextReader(AbstractAsyncContextManager):
417
406
  self.__buffer = ""
418
407
 
419
408
  async def __read_next_chunk(self) -> str:
420
- return (await anext(self.__reader, b"")).decode(self.__encoding)
409
+ return (await _compat.anext(self.__reader, b"")).decode(self.__encoding)
421
410
 
422
411
  async def __aenter__(self) -> "AsyncBufferedTextReader":
423
412
  return self
424
413
 
425
- async def __aexit__(
426
- self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
427
- ) -> bool | None:
414
+ async def __aexit__(self, exc_type, exc_value, traceback) -> Optional[bool]:
428
415
  return await self.close()
429
416
 
430
417
  async def __aiter__(self) -> AsyncIterator[str]:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "flatfs"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Minimal filesystem abstraction with pluggable backends, treating paths as keys and file contents as values."
5
5
  authors = [
6
6
  {name = "Maciej Wiatrzyk", email = "maciej.wiatrzyk@gmail.com"}
@@ -15,7 +15,7 @@ classifiers = [
15
15
  "Operating System :: OS Independent",
16
16
  "Topic :: Software Development :: Libraries",
17
17
  ]
18
- requires-python = ">=3.10,<4"
18
+ requires-python = ">=3.9,<4"
19
19
  dependencies = [
20
20
  ]
21
21
 
@@ -28,11 +28,11 @@ requires = ["poetry-core>=2.0.0,<3.0.0"]
28
28
  build-backend = "poetry.core.masonry.api"
29
29
 
30
30
  [tool.poetry.group.dev.dependencies]
31
- pytest = "^9.0.3"
31
+ pytest = "^8.4.2"
32
32
  invoke = "^3.0.3"
33
- pytest-asyncio = "^1.3.0"
33
+ pytest-asyncio = "^1.2.0"
34
34
  mockify = "^0.14.0"
35
35
  pytest-cov = "^7.1.0"
36
36
  ruff = "^0.15.12"
37
- mypy = "^2.0.0"
37
+ mypy = "^1.19.1"
38
38
  bumpify = "^0.5.1"
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes