python-filewrap 0.0.7.1__tar.gz → 0.0.7.2__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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-filewrap
3
- Version: 0.0.7.1
3
+ Version: 0.0.7.2
4
4
  Summary: Python file wrappers.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-filewrap
6
6
  License: MIT
@@ -4,7 +4,7 @@
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
5
  __version__ = (0, 0, 7)
6
6
  __all__ = [
7
- "SupportsRead", "SupportsWrite",
7
+ "SupportsRead", "SupportsWrite", "SupportsSeek",
8
8
  "bio_chunk_iter", "bio_chunk_async_iter",
9
9
  "bio_skip_iter", "bio_skip_async_iter",
10
10
  "bytes_iter_skip", "bytes_async_iter_skip",
@@ -14,11 +14,10 @@ __all__ = [
14
14
  ]
15
15
 
16
16
  from asyncio import to_thread, Lock as AsyncLock
17
- from collections.abc import Awaitable, AsyncIterable, Iterable
17
+ from collections.abc import Awaitable, AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
18
18
  from functools import update_wrapper
19
19
  from inspect import isawaitable, iscoroutinefunction
20
20
  from itertools import chain
21
- from collections.abc import AsyncIterator, Callable, Iterator
22
21
  from shutil import COPY_BUFSIZE # type: ignore
23
22
  from threading import Lock
24
23
  from typing import runtime_checkable, Any, Protocol, TypeVar
@@ -37,12 +36,17 @@ _T_contra = TypeVar("_T_contra", contravariant=True)
37
36
 
38
37
  @runtime_checkable
39
38
  class SupportsRead(Protocol[_T_co]):
40
- def read(self, __length: int = ...) -> _T_co: ...
39
+ def read(self, /, __length: int = ...) -> _T_co: ...
41
40
 
42
41
 
43
42
  @runtime_checkable
44
43
  class SupportsWrite(Protocol[_T_contra]):
45
- def write(self, __s: _T_contra) -> object: ...
44
+ def write(self, /, __s: _T_contra) -> object: ...
45
+
46
+
47
+ @runtime_checkable
48
+ class SupportsSeek(Protocol[_T_contra]):
49
+ def seek(self, /, __offset: int, __whence: int = 0) -> int: ...
46
50
 
47
51
 
48
52
  def bio_chunk_iter(
@@ -187,6 +191,7 @@ async def bio_skip_async_iter(
187
191
  if size == 0:
188
192
  return
189
193
  callback = ensure_async(callback) if callable(callback) else None
194
+ length: int
190
195
  try:
191
196
  seek = ensure_async(getattr(bio, "seek"))
192
197
  curpos = await seek(0, 1)
@@ -271,7 +276,7 @@ def bytes_iter_skip(
271
276
 
272
277
 
273
278
  async def bytes_async_iter_skip(
274
- it: Iterable[Buffer] | AsyncIterator[Buffer],
279
+ it: Iterable[Buffer] | AsyncIterable[Buffer],
275
280
  /,
276
281
  size: int = -1,
277
282
  callback: None | Callable[[int], Any] = None,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-filewrap"
3
- version = "0.0.7.1"
3
+ version = "0.0.7.2"
4
4
  description = "Python file wrappers."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"